4
后,我设法获取谷歌联系API的访问令牌,但当我尝试拨打电话以检索登录用户的配置文件时,我收到401未经授权的错误。 。Google Contacts API - 获取访问令牌(oauth)
我做了一些研究,并遵循“不同”中提到的步骤谷歌单证(如this one和this one等等),但没有用...
到目前为止,我想我请求签名错误。这是我在获取访问令牌后所做的事情。发送使用oAuth.WebRequest()(上述代码的最后一行)
我只需要摆脱401错误的......我的请求时出现
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);
的401错误使用ASP.NET/C#。任何帮助,将不胜感激。谢谢...
对不起,连续9个小时的工作让我的头脑乱了一下。我在WebRequest中使用reqURL。我将编辑我的问题来解决它,谢谢指出它。我会尝试在授权标题中提供参数并查看会发生什么情况。这让我感到困惑,因为我已经做过twitter,yahoo,LIVE和其他许多其他的事情,我只需要做一个响应就可以做到http(s):// RequestURL /?access_token = _ACCESS_TOKEN_并且它可以工作。我会尝试你的建议,谢谢。 – Reyno 2012-01-17 18:29:58
谢谢,那是为我做的。看完你的代码后,我意识到如何发送带有授权标头的请求,而不是用querystring发送它。非常感谢! – Reyno 2012-01-18 08:20:56