【问题标题】:flickr oauth signature invalid errorflickr oauth 签名无效错误
【发布时间】:2013-06-26 06:50:01
【问题描述】:

我正在使用 OauthBase.cs 类生成签名,但我经常收到错误消息,指出签名无效。谁能告诉我哪里出错了?

我暂时将其显示在消息框中,然后将其复制并粘贴到浏览器中以进行检查。

这是我的代码..

        string consumerKey = "consumer_key";
        string consumerSecret = "consumer_secret";

        string normalizedUrl = null;
        string normalizedRequestParameters = null;


        Uri url = new Uri("http://www.flickr.com/services/oauth/request_token");
        oAuthBase oAuth = new oAuthBase();

        string nonce = oAuth.GenerateNonce();
        string timeStamp = oAuth.GenerateTimeStamp();
        string callback = oAuth.UrlEncode("http://www.example.com");
        string sig = oAuth.GenerateSignature(url, consumerKey, consumerSecret, string.Empty   , string.Empty , "GET", timeStamp, nonce, callback , oAuthBase.SignatureTypes.HMACSHA1,out normalizedUrl ,out normalizedRequestParameters );
        sig = HttpUtility.UrlEncode(sig);
        StringBuilder sb = new StringBuilder(url.ToString());


        sb.AppendFormat("?oauth_nonce={0}&", nonce);
        sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
        sb.AppendFormat("oauth_consumer_key={0}&", consumerKey);
        sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");           

        sb.AppendFormat("oauth_version={0}&", "1.0");

        sb.AppendFormat("oauth_signature={0}", sig);
        sb.AppendFormat("oauth_callback={0}", callback);


        MessageBox.Show(sb.ToString());

【问题讨论】:

标签: c#


【解决方案1】:

从昨天开始我就一直在做同样的事情。不管我做了什么,我总是得到 invalid_signature。

然后我尝试使用http://flickrnet.codeplex.com/,效果很好。我可以建议你使用它。或者也许查看源代码,这可能会帮助您找到代码的问题。

希望对你有帮助:)

【讨论】:

  • flickrnet 可以工作,但是我的应用程序大小增加了,因为我不需要其中列出的所有类,所以我尝试使用 oAuthBase 类。
猜你喜欢
  • 1970-01-01
  • 2012-09-17
  • 1970-01-01
  • 2011-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多