I am also having a problem with 401 error when trying to get a request token from yahoo contact api. I am using the latest OAuthBase.cs
This is very frustrating I don't know why it has to be so complicated to get this working. PLEASE HELP!!!!
Here is the code being used:
Uri YahooAuthRequestToken = new Uri("https://api.login.yahoo.com/oauth/v2/get_request_token");
OAuth.OAuthBase oAuth = new OAuth.OAuthBase();
string nonce = oAuth.GenerateNonce();
string timeStamp = oAuth.GenerateTimeStamp();
string sig = oAuth.GenerateSignature(YahooAuthRequestToken,
consumerKey, consumerSecret,
string.Empty, string.Empty,
"GET", timeStamp, nonce,
OAuth.OAuthBase.SignatureTypes.HMACSHA1,out normaluri , out normaluriparam);
sig = HttpUtility.UrlEncode(sig);
StringBuilder sb = new StringBuilder(YahooAuthRequestToken.ToString());
sb.AppendFormat("?oauth_callback={0}&", "oob");
sb.AppendFormat("oauth_consumer_key={0}&", consumerKey);
sb.AppendFormat("oauth_nonce={0}&", nonce);
sb.AppendFormat("oauth_timestamp={0}&", timeStamp);
sb.AppendFormat("oauth_signature_method={0}&", "HMAC-SHA1");
sb.AppendFormat("oauth_version={0}&", "1.0");
sb.AppendFormat("oauth_signature={0}", sig.ToString());
try
{
request = WebRequest.Create(sb.ToString()) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader GetAuthToken = new StreamReader(response.GetResponseStream());
YahooAuthToken = GetAuthToken.ReadToEnd();
MessageBox.Show(YahooAuthToken);
}
}
catch (Exception ex)
{
MessageBox.Show( "ERROR: " + ex.Message);
}
HERE IS THE VALUE OF sb.ToString() in the WebRequest.Create(sb.ToString()
https://api.login.yahoo.com/oauth/v2/get_re...llback=oob&oauth_consumer_key=dj0yJmk0bd...(REMOVED FOR MY APP SECURTIY)...meD1kMw--
&oauth_nonce=4228703&oauth_timestamp=126890185&oauth_signature
_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=kSUT6rXzpTgnDwdmbHMAjNQjOZU%3d