我正在尝试通过Google .Net GData客户端库生成OAuth访问令牌.我一直在使用http://code.google.com/apis/gdata/docs/auth/oauth.html中的说明作为指导,所有内容一直在进行,直到我尝试拨打电话OAuthUtil.GetAccessToken( parameters ),我收到了"(400) )错误请求"网络例外.
不幸的是,它没有告诉我为什么这是一个糟糕的请求.所以,我对此感到困惑.我唯一的想法就是,因为我使用的是localhost网址,但它不起作用(虽然我已经在Google API控制台中注册了网址,但这样做似乎没问题).
我在这里做错了什么以及我应该做些什么才能做到正确?
该OAuthParameters对象被创建像这样(的敏感数据被审查,希望并不能使它很难回答):
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>
Run Code Online (Sandbox Code Playgroud)
这转换为Web响应的标题,如下所示:
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>
Run Code Online (Sandbox Code Playgroud)
(为了便于阅读,增加了换行符)
注意:上述编辑值在GData代码相关的位置正确编码.
请求uri是: https://www.google.com/accounts/OAuthGetAccessToken
根据位于此处的类,第186行发生错误:http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r = 112
这可能与您在范围中指定的 URL 完全无关
https://docs.google.com/calendar/feeds/
返回 404 错误
我认为你应该使用以下内容:
http://www.google.com/calendar/feeds/default/
或者可能http://www.google.com/calendar/feeds/default/owncalendars/full