0

401 Unauthorized

 I'm developping a C# web app in wich i need to access some data form fantasy API. I'm unable to get to authentication token and I'm really wondering what I'm doing wrong :
      var builder = new StringBuilder();      builder.Append("https://api.login.yahoo.com/oauth/v2/get_request_token");      builder.Append("?oauth_nonce=" + Guid.NewGuid().ToString());      builder.Append("&oauth_timestamp=" + ((DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks) / (1000 * 10000)).ToString());      builder.Append("&oauth_consumer_key={the key i was given}");      builder.Append("&oauth_signature_method=plaintex");      builder.Append("&oauth_signature={the consumer secret i was given}%26");      builder.Append("&oauth_version=1.0 ");      builder.Append("&xoauth_lang_pref=\"en-us\"");      builder.Append("&oauth_callback=\"oob\"");      var httpWebRequest = (HttpWebRequest)WebRequest.Create(builder.ToString());      httpWebRequest.ContentType = "application/x-www-form-urlencoded ";      httpWebRequest.Method = "POST";

by
2 Replies
  •  reformatted code snippet here

    var builder = new StringBuilder();
    builder.Append("https://api.login.yahoo.com/oauth/v2/get_request_token");
    builder.Append("?oauth_nonce=" + Guid.NewGuid().ToString());
    builder.Append("&oauth_timestamp=" + ((DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks) / (1000 * 10000)).ToString());
    builder.Append("&oauth_consumer_key={the key i was given}"); builder.Append("&oauth_signature_method=plaintex");
    builder.Append("&oauth_signature={the consumer secret i was given}%26"); builder.Append("&oauth_version=1.0 ");
    builder.Append("&xoauth_lang_pref=\"en-us\""); builder.Append("&oauth_callback=\"oob\"");

    var httpWebRequest = (HttpWebRequest)WebRequest.Create(builder.ToString());
    httpWebRequest.ContentType = "application/x-www-form-urlencoded ";
    httpWebRequest.Method = "POST";

    0
  • I see a "plaintex" instead of "plaintext" in there. Perhaps try to change that and see if it helps? Also, why are you POSTing? I believe you'd want to GET instead?
    0

Recent Posts

in Fantasy Sports API