I use the OauthBase.cs class to generate a signature, but I constantly get an error message indicating that the signature is not valid. Can someone tell me where I am going wrong?
I temporarily show it in a message box, copying and pasting it in a browser to check it.
Here is my code ..
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());
source share