[英]LinkedIn Access Token Request - signature invalid
I have following code. 我有以下代码。 During the first stage (obtaining OAuth Token) everything works fine, but in the Callback (during obtaining Access Token) I get signature invalid error.
在第一阶段(获取OAuth令牌),一切正常,但在回调(获取访问令牌期间)中,我收到签名无效错误。 Does anyone could help me with the answer what am I doing wrong?
有人可以帮助我回答我在做什么错吗?
public ActionResult LinkedInTest(string text)
{
var credentials = new OAuthCredentials
{
CallbackUrl = "http://localhost:60739/Calendar/Callback",
ConsumerKey = ApiKey,
ConsumerSecret = ApiSecret,
Verifier = "123456",
Type = OAuthType.RequestToken
};
var client = new RestClient {Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials};
var request = new RestRequest {Path = "requestToken"};
RestResponse response = client.Request(request);
token = response.Content.Split('&')[0].Split('=')[1];
textToPost = text;
Response.Redirect("https://api.linkedin.com/uas/oauth/authorize?oauth_token=" + token);
return null;
}
public ActionResult Callback()
{
token = Request["oauth_token"];
verifier = Request["oauth_verifier"];
var credentials = new OAuthCredentials
{
ConsumerKey = ApiKey,
ConsumerSecret = ApiSecret,
Token = token,
TokenSecret = "",
Verifier = verifier,
Type = OAuthType.AccessToken,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
Version = "1.0"
};
var client = new RestClient
{
Authority = "https://api.linkedin.com/uas/oauth",
Credentials = credentials,
Method = WebMethod.Post
};
var request = new RestRequest {Path = "accessToken"};
RestResponse response = client.Request(request);
return Content(response.Content);
}
An excellent guide for working with LinkedIn REST API: 使用LinkedIn REST API的绝佳指南:
http://www.suddenelfilio.net/2010/08/24/linkedin-oauth-using-hammock-in-csharp-asp-net/ http://www.suddenelfilio.net/2010/08/24/linkedin-oauth-using-hammock-in-csharp-asp-net/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.