【发布时间】:2012-02-12 09:37:55
【问题描述】:
我设法获得了谷歌联系人 API 的访问令牌,但是当我尝试调用以检索已登录用户的个人资料时,我收到 401 未经授权的错误...
我做了一些研究并按照“各种”谷歌文档中提到的步骤(如this one 和this one 以及许多其他人)但没有用......
到目前为止,我认为我签署的请求是错误的。这是我获得访问令牌后正在做的事情。
string outUrl,querystring;
string sig = oAuth.GenerateSignature(new Uri("https://www.google.com/m8/feeds/contacts/default/full"), Server.UrlEncode(oAuth.ConsumerKey), oAuth.ConsumerSecret, oAuth.Token, null, "GET", timeStamp, nonce, out outUrl, out querystring);
string reqURL = "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + oAuth.Token + "&oauth_signature_method=HMAC-SHA1&oauth_signature=" + Server.UrlEncode(sig) + "&oauth_consumer_key=" + oAuth.ConsumerKey + "&oauth_timestamp=" + timeStamp + "&oauth_nonce=" + nonce + "&oauth_version=1.0";
response = oAuth.WebRequest(oAuthGoogle.Method.GET, reqURL, String.Empty);
使用oAuth.WebRequest()发送请求时出现401错误(上面代码的最后一行)
我只需要摆脱 401 错误...我正在使用 ASP.NET/C#。任何帮助,将不胜感激。谢谢...
【问题讨论】: