1
我目前正在努力開發谷歌閱讀器的API,當我試圖讓令牌,正在生成以下錯誤:爲什麼google服務器在嘗試獲取令牌時返回錯誤401?
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
首先,我得到了會議...和這工作完美。那麼下面的方法我被稱爲獲得令牌:
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;
}
在這條線所產生的異常:
response= (HttpWebResponse)request.GetResponse();
沒有人知道什麼可能導致這個錯誤嗎?
PS。我閱讀了這個問題:Why am I getting a 401 (Unauthorized) error when POSTing to Google Reader API?但是當他試圖發佈時他得到這個錯誤。