- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过 Google .Net GData 客户端库生成 OAuth 访问 token 。我一直在使用 http://code.google.com/apis/gdata/docs/auth/oauth.html 中的说明作为指导,一切都在进行,直到我尝试调用 OAuthUtil.GetAccessToken( parameters )
此时我收到“(400) Bad Request”网络异常。
不幸的是,它没有告诉我任何关于为什么这是一个糟糕的请求的信息。所以,我对此有点困惑。我唯一的想法是,因为我正在使用 localhost
url 不起作用(尽管我已经在 Google API 控制台中注册了该 url,而且这样做似乎没问题)。
有什么想法我在这里做错了什么以及我应该做什么来纠正它吗?
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>
这会转换为网络响应的 header ,如下所示:
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>
(为了便于阅读而添加换行符)
注意:上述编辑值在与 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=1123
最佳答案
这可能与您在范围内指定的 URL 完全无关
https://docs.google.com/calendar/feeds/
返回404错误
我认为您应该使用以下内容:
http://www.google.com/calendar/feeds/default/
或者可能http://www.google.com/calendar/feeds/default/owncalendars/full
关于.net - Google GData .Net OAuthUtil.GetAccessToken 400 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9484491/
当我使用 Google.GData.Client .NET 库并尝试启动 OAuth session 时,它可以正常工作,直到 session 过期。当我执行初始 GetAccessToken 请求时
我正在使用 oauth 从桌面应用程序获取对 google 联系人的访问权限。我在这里遵循了谷歌的说明:http://code.google.com/intl/iw-IL/apis/gdata/doc
我正在尝试通过 Google .Net GData 客户端库生成 OAuth 访问 token 。我一直在使用 http://code.google.com/apis/gdata/docs/auth/
我是一名优秀的程序员,十分优秀!