سؤال

i'm currently trying to develop an api for google reader and when i'm trying to get the token, the following error is being generated:

System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()

first i'm getting the session... and this works perfectly. then the following method i being called to get the token:

public String setToken()
{
    HttpWebResponse response;
    HttpWebRequest request;
    cookie = new Cookie("SID", this.sessionID, "/", ".google.com");
    String url = "http://www.google.com/reader/api/0/token";

    request = (HttpWebRequest)WebRequest.Create(url);
    request.Method = "GET";
    request.CookieContainer = new CookieContainer();
    request.CookieContainer.Add(this.cookie);

    response= (HttpWebResponse)request.GetResponse();
    using (var stream = response.GetResponseStream())
    {
        StreamReader r = new StreamReader(stream);
        this.token = r.ReadToEnd();
    }
    return this.token;
}

the exception is being generated in this line:

response= (HttpWebResponse)request.GetResponse();

does anyone know what might be causing this error please?

PS. I read the question : Why am I getting a 401 (Unauthorized) error when POSTing to Google Reader API? however he was getting this error when he tried to post.

هل كانت مفيدة؟

المحلول

Google has changed, according to Eric Mann:

"As it turns out, Google has changed the authentication portion of the Reader API. Now, instead of passing the SID in a cookie when you make a request, you set an authentication header with the “Auth” key originally passed with the SID."

Source

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top