本文介绍了谷歌的GData净OAuthUtil.GetAccessToken 400错误的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想产生通过谷歌的.Net的GData客户端库OAuth访问令牌。我一直在使用的 HTTP说明:// code.google.com /原料药/ GDATA /文档/认证/ oauth.html 为指导,一切都已经工作了,直到笔者试图调用 OAuthUtil.GetAccessToken(参数)在这一点上我收到(400)错误的请求的网络异常。

I'm trying generate an OAuth access token via the Google .Net GData Client Library. I've been using the instructions in http://code.google.com/apis/gdata/docs/auth/oauth.html as a guide and everything's been working up until I attempt calling OAuthUtil.GetAccessToken( parameters ) at which point I receive a "(400) Bad Request" web exception.

不幸的是,它没有告诉我任何事情的为什么的这是一个错误的请求。所以,我有点困惑这个问题。我唯一​​的想法是这样的,因为我使用了一个本地主机 URL它不工作(虽然我已经注册的网址在谷歌API控制台,它似乎是好的这样做的)。

Unfortunately, it's not telling me anything about why it's a bad request. So, I'm kinda baffled about this. The only idea I have is that, because I'm using a localhost url it's not working (though I have registered the url in the Google API Console and it seemed to be okay to do so).

任何想法,我做错了什么,我应该做的,以作出正确的?

Any ideas what I'm doing wrong here and what I should be doing to make it right?

OAuthParameters 对象像这样(的敏感数据审查,希望并不能使它很难回答的)构建P>

The OAuthParameters object is constructed like so (sensitive data is censored, hope that doesn't make it hard to answer):

BaseProperties:
    oauth_consumer_key:     <CLIENT_KEY>,
    oauth_nonce:            <NONCE>
    oauth_signature_method: HMAC-SHA1
    oauth_timestamp:        1330440325
    oauth_token:            <TOKEN>
    oauth_verifier:         <VERIFIER>
Callback:        "http://localhost:57381/subscription_auth.aspx?c=google.calendar"
ConsumerKey:     <CLIENT_KEY>
ConsumerSecret:  <CLIENT_SECRET>
ExtraProperties
    oauth_consumer_secret: <CLIENT_SECRET>
    scope:                 https://docs.google.com/calendar/feeds/
    oauth_callback:        http://localhost:57381/subscription_auth.aspx?c=google.calendar
Nonce:           <NONCE>
Scope:           "https://docs.google.com/calendar/feeds/"
Signature:       NULL
SignatureMethod: "HMAC-SHA1"
Timestamp:       "1330440325"
Token:           <TOKEN>
TokenSecret:     NULL  -- No Token Secret was returned from the callback.
Verifier:        <VERIFIER>

这意味着标题的网页响应这是像这样:

This translates into headers for the web response which are like so:

Authorization: OAuth oauth_version="1.0",
oauth_nonce=<NONCE>,
oauth_timestamp="1330441324",
oauth_consumer_key=<CLIENT_KEY>,
oauth_verifier=<VERIFIER>,
oauth_token=<TOKEN>,
oauth_signature_method="HMAC-SHA1",
oauth_signature=<SIGNATURE>

(换行增加了可读性)

注:以上节录值均设有codeD正确的地方的的GData code相关的

NOTE: The above redacted values are encoded correctly where relevant by the GData code.

和请求URI是: https://www.google.com/accounts/OAuthGetAccessToken

根据该错误的行处发生186根据设在这里的类:<一href="http://$c$c.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123" rel="nofollow">http://$c$c.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123

The error's happening at line 186 as per the class located here: http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123

推荐答案

这可能是完全不相关的,但你已经在你的范围内指定的URL

This may be completely unrelated but the URL you have specified in your scope

https://docs.google.com/calendar/feeds/

返回404错误

我觉得你应该用以下代替:

I think you should be using the following instead:

http://www.google.com/calendar/feeds/default/

或可能 http://www.google.com/calendar/feeds/default/owncalendars/full

这篇关于谷歌的GData净OAuthUtil.GetAccessToken 400错误的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 11:16