tags:

views:

77

answers:

1

Hi there,

My below code returns a 401 Unauthorized error each time at the this point:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://query.yahooapis.com/v1/yql?q=select%20fields.value%20from%20social.contacts%20where%20guid%3Dme&diagnostics=false");

            request.Headers.Add(
            "Authorization: OAuth " +
            "realm=\"" + "yahooapis.com" + "\"," +
            "oauth_consumer_key=\"" + ConfigurationManager.AppSettings["yahoo_oauth_consumer_key"] + "\"," +
            "oauth_nonce=\"" + Guid.NewGuid().ToString() + "\"," +
            "oauth_signature_method=\"" + "PLAINTEXT" + "\"," +
            "oauth_timestamp=\"" + ((DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks) / (1000 * 10000)).ToString() + "\"," +
            "oauth_token=\"" + accessToken.TokenValue + "\"," +
            "oauth_version=\"1.0" + "\"," +
            "oauth_signature=\"" + ConfigurationManager.AppSettings["yahoo_oauth_signature"] + "%26" + "\""
            );

            StreamReader streamReader = new StreamReader(request.GetResponse().GetResponseStream(), true);

And when I step into the code everytime I see all the info is there that Yahoo requests to have in the header, yet everytime I get this 401.

A: 

Ok first of all:

http://www.youtube.com/watch?v=lZLP0siJI-8&feature=related

Secondly, the solution;

Don't run it from localhost :P

When I signed up on Yahoo I should've read more carefully, I signed up a second time just to see, and it clearly states from which domain will you be making the calls to our APIs.

Nicholas