23

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;
}
2
  • Have you tried looking at the DNOA samples? dotnetopenauth.net Commented Feb 14, 2013 at 13:43
  • yes but not working. updated the question Commented Feb 14, 2013 at 14:04

2 Answers 2

14

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I would prefer client based such as wpf if possible
The MVC application uses OAuth1 as opposed to OAUth2.
Microsoft.Security.OWIN.OAuth uses OAuth 2:- nuget.org/packages/Microsoft.Owin.Security.OAuth
1

In the ASP.NET Core Security Project there is now a ready to use solution:

Nuget Package: AspNet.Security.OAuth.DeviantArt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.