我必须弄清楚如何使用 OAuth 2 才能使用 Deviantart api。
我得到了 client_id 和 client_secret 部分
这是他们提供的信息
端点
使用 OAuth 2.0 向我们进行身份验证时所需的唯一信息是client_id
and client_secret
您的应用程序的值以及如下所示的端点。
OAuth 2.0 草案 10:
https://www.deviantart.com/oauth2/draft10/authorize https://www.deviantart.com/oauth2/draft10/authorize
https://www.deviantart.com/oauth2/draft10/token https://www.deviantart.com/oauth2/draft10/token
OAuth 2.0 草案 15:
https://www.deviantart.com/oauth2/draft15/authorize https://www.deviantart.com/oauth2/draft15/authorize
https://www.deviantart.com/oauth2/draft15/token https://www.deviantart.com/oauth2/draft15/token
安慰剂通话
第一个依赖 OAuth 2.0 身份验证的 API 调用是安慰剂调用。
它对于在进行可能很长的实际 API 调用(例如文件上传)之前检查访问令牌是否仍然有效非常有用。
您可以使用以下端点之一调用它(必须提供访问令牌):
https://www.deviantart.com/api/draft10/placebo https://www.deviantart.com/api/draft10/placebo
https://www.deviantart.com/api/draft15/placebo https://www.deviantart.com/api/draft15/placebo
您需要使用与您获取令牌所用的 OAuth 2.0 草案相对应的端点。
它始终返回以下 JSON:{status: "success"}
我在网上搜索并发现了这个很棒的图书馆。
DotNetOpenAuth v4.0.1
http://www.dotnetopenauth.net/ http://www.dotnetopenauth.net/
添加它作为参考,但不知道下一步该怎么做。即使是一个非常小的示例对于如何使用 OAuth 2 也非常有用
using DotNetOpenAuth;
using DotNetOpenAuth.OAuth2;
这是 deviantart 提供信息的页面
http://www.deviantart.com/developers/oauth2 http://www.deviantart.com/developers/oauth2
好的,这是我到目前为止所得到的但不起作用
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;
}