无法验证 oauth 签名和令牌 - 问题 javascript
我尝试通过以下 url 获取访问令牌
https://api.twitter.com/oauth/request_token?
oauth_consumer_key=vRtqh0KONqxr1C2knqv2A&
oauth_nonce=0afa694efd3feee68ebc180f3858a9a3&
oauth_signature=QgHBQ8OLBrjgwivzIfe4p9eBtaQ%3D&
oauth_signature_method=HMAC-SHA1&
oauth_timestamp=1328989636&
oauth_version=1.0
,但错误是“无法验证 oauth 签名和令牌”。这个网址有什么问题吗??
I am trying to get access token by following url
https://api.twitter.com/oauth/request_token?
oauth_consumer_key=vRtqh0KONqxr1C2knqv2A&
oauth_nonce=0afa694efd3feee68ebc180f3858a9a3&
oauth_signature=QgHBQ8OLBrjgwivzIfe4p9eBtaQ%3D&
oauth_signature_method=HMAC-SHA1&
oauth_timestamp=1328989636&
oauth_version=1.0
But the error is "Failed to validate oauth signature and token". What is wrong with this url??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的系统时间配置正确吗??????
Is your system time is properly configured???????
我们收到此错误“无法验证 OAuth 签名和令牌”的原因之一是系统时间错误。由于 OAuth 请求携带系统时间戳参数,因此当设备时间不在 Twitter 服务器时间的 5 分钟内时,我们会收到“无法验证 OAuth 签名和令牌”。
如果这是原因,并且您希望它在系统时间也错误的情况下也能工作,那么有两种方法可以使其工作:
向 api.twitter.com 上的端点发出 HTTP HEAD 请求 - 您将在响应中获得一个 Date HTTP 标头,指示 Twitter 理解的当前时间。然后,您可以将其转换为纪元时间,并按确定的偏移量调整您的
oauth_timestamp
值。有一个小型 iOS 库 ios-ntp。用它来获取准确的当前时间。
之后在以下方法中设置OAuth对象的时间戳
就是这样......快乐编码:)
One of the reason we get this error "Failed to validate OAuth signature and token" is when system time is wrong. Because OAuth request carry system timestamp parameters with it, when the device time is not within the 5 minutes of Twitter's server time, we get "Failed to validate OAuth signature and token".
If this is the reason, and you want it to make work if the system time is wrong also, then there are two ways to make it work:
Make HTTP HEAD request to an endpoint on api.twitter.com -- you'll get a Date HTTP header in the response that indicates the current time understood by Twitter. You would then convert this to epoch time and adjust your
oauth_timestamp
values by a determined offset.There's a small iOS library ios-ntp. Use this to get the accurate current time.
After that set the timestamp of OAuth object in the following method
That's it... Happy coding :)