1

次のコードがあります。最初の段階(OAuthトークンの取得)ではすべてが正常に機能しますが、コールバック(アクセストークンの取得中)では、署名が無効なエラーが発生します。誰かが私が間違っていることの答えを手伝ってくれるでしょうか?

        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);
    }
4

1 に答える 1

0

LinkedIn REST APIを使用するための優れたガイド:

http://www.suddenelfilio.net/2010/08/24/linkedin-oauth-using-hammock-in-csharp-asp-net/

于 2012-11-12T14:52:29.613 に答える