How to use OAuth 2 - OAuth 2 C# example

91,219

Easiest thing to do now is get Visual Studio 2013 and create a new ASP.NET Web Application choosing "Individual User Accounts" as your authentication type. There's a working OAuth 2 implementation out of the box in there (configured at App_Start\Startup.Auth.cs) which you can slice out and then adapt to your needs.

Share:
91,219

Related videos on Youtube

MonsterMMORPG
Author by

MonsterMMORPG

Hello. I am the only owner and developer of web based online MMORPG game MonsterMMORPG. I am a computer engineer from Turkey and i am currently doing MA at computer engineering. I am specialized with C# & ASP.net. http://www.monstermmorpg.com/ MonsterMMORPG is a Free To Play Browser Based Online Monster MMORPG Game Better Than Online Pokemon Games You will love it's awesome Monsters We have many different unique features. So i suggest you to check them out. Our game is similiar with Pokemon games but it is unique. Like diablo and torch light. You should visit following sites related to us MonsterMMORPG Facebook Pokemon Games Lovers Facebook Application MonsterMMORPG Youtube Channel Monster Game Forum Canavar Oyunu Forum Pokemon Fakemon DeviantArt MonsterMMORPG Google Plus MonsterMMORPG Twitter MonsterMMORPG Review On Browsergamez MonsterMMORPG Review On mmohuts MonsterMMORPG Developer Blog At MMORPG.com MonsterMMORPG Review On onrpg MonsterMMORPG On GameSpot MonsterMMORPG Wiki MonsterMMORPG On 1UP MonsterMMORPG Digg MonsterMMORPG Official Google Plus Page

Updated on June 06, 2022

Comments

  • MonsterMMORPG
    MonsterMMORPG almost 2 years

    I have to figure out how to use OAuth 2 in order to use Deviantart api.

    I got the client_id and client_secret part

    Here the information they give

    Endpoints

    The only information you need to authenticate with us using OAuth 2.0 are the client_id and client_secret values for your app, as well as the endpoint shown below.

    OAuth 2.0 draft 10:

    https://www.deviantart.com/oauth2/draft10/authorize https://www.deviantart.com/oauth2/draft10/token

    OAuth 2.0 draft 15:

    https://www.deviantart.com/oauth2/draft15/authorize https://www.deviantart.com/oauth2/draft15/token

    Placebo call

    The first API call relying on OAuth 2.0 authentication is the placebo call. It's useful for checking that an access token is still valid before making a real API call that might be long, like a file upload. You call it with one of the following endpoints (an access token must be provided):

    https://www.deviantart.com/api/draft10/placebo https://www.deviantart.com/api/draft15/placebo

    You need to use the endpoint that corresponds to the OAuth 2.0 draft you've obtained your token with.

    It always returns the following JSON: {status: "success"}

    I have searched the web and found this awesome library.

    DotNetOpenAuth v4.0.1

    http://www.dotnetopenauth.net/

    Added it as reference but have no idea what to do next. Even a very small example would be really useful about how to use OAuth 2

    using DotNetOpenAuth;
    using DotNetOpenAuth.OAuth2;
    

    Here the page where deviantart gives the information

    http://www.deviantart.com/developers/oauth2

    Ok here what i got so far but not working

    public static WebServerClient CreateClient() {
        var desc = GetAuthServerDescription();
        var client = new WebServerClient(desc, clientIdentifier: "myid");
        client.ClientCredentialApplicator = ClientCredentialApplicator.PostParameter("mysecret");
        return client;
    }
    
    public static AuthorizationServerDescription GetAuthServerDescription() {
        var authServerDescription = new AuthorizationServerDescription();
        authServerDescription.AuthorizationEndpoint = new Uri(@"https://www.deviantart.com/oauth2/draft15/authorize");
        authServerDescription.TokenEndpoint = new Uri(@"https://www.deviantart.com/oauth2/draft15/token");
        authServerDescription.ProtocolVersion = ProtocolVersion.V20;
        return authServerDescription;
    }
    
  • MonsterMMORPG
    MonsterMMORPG about 11 years
    I would prefer client based such as wpf if possible
  • Captain Kenpachi
    Captain Kenpachi over 10 years
    The MVC application uses OAuth1 as opposed to OAUth2.
  • Iain Galloway
    Iain Galloway over 10 years
    Microsoft.Security.OWIN.OAuth uses OAuth 2:- nuget.org/packages/Microsoft.Owin.Security.OAuth