gpt4 book ai didi

curl - 获取 401 未经授权 : "Failed to validate oauth signature and token" when running cURL command produced by oauth tool

转载 作者:行者123 更新时间:2023-12-04 02:39:05 26 4
gpt4 key购买 nike

我在 dev.twitter.com 的“我的应用程序”页面中使用 OAuth 工具来生成用于获取 OAuth request_token 的 cURL 命令。但是当我运行 cURL 命令时,我总是收到 401 Unauthorized 响应。谁能帮忙?

注意事项:

  • 我在下面的输出中屏蔽了 oauth_token 的值。
  • 我的 Twitter 应用程序是“读取、写入和访问直接消息”类型
  • 应用程序设置页面中的“回调 URL”字段留空,因为我希望使用 oob 值。
  • 我还尝试将 oauth_callback=oob 放在 Authorization header 中而不是 POST 数据中

这是生成的 cURL 命令:

curl --request 'POST' 'http://api.twitter.com/oauth/request_token' --data 'oauth_callback=oob' --header 'Authorization: OAuth oauth_consumer_key="tE5nLRh4gcSB3hsQc8iPw", oauth_nonce="94408715574f443f45d6f291d0105bd6", oauth_signature="xA70n%2FXPUQ1EuGjdtf6jz9J%2FZUs%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1385744996", oauth_token="******", oauth_version="1.0"' --verbose

上述 cURL 命令的输出:

* About to connect() to api.twitter.com port 80 (#0)
* Trying 199.59.149.199... connected
* Connected to api.twitter.com (199.59.149.199) port 80 (#0)
> POST /oauth/request_token HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8y zlib/1.2.5
> Host: api.twitter.com
> Accept: */*
> Authorization: OAuth oauth_consumer_key="tE5nLRh4gcSB3hsQc8iPw", oauth_nonce="4a5cc00de2b606e0f8a739194e21d7af", oauth_signature="IBoBxEpymr2hYMLSISrzHRucbEc%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1385744052", oauth_token="**********", oauth_version="1.0"
> Content-Length: 18
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 401 Unauthorized
< cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
< content-length: 44
< content-type: text/html; charset=utf-8
< date: Fri, 29 Nov 2013 17:10:28 GMT
< expires: Tue, 31 Mar 1981 05:00:00 GMT
< last-modified: Fri, 29 Nov 2013 17:10:28 GMT
< pragma: no-cache
< server: tfe
< set-cookie: _twitter_sess=BAh7CDoHaWQiJTc3YzFiYTFiMzNlMTZmYzVhMjFkODdlMGIwN2FlMDk1Og9j%250AcmVhdGVkX2F0bCsIARbXpEIBIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--d3b782133d5b46e57716bb0bd8da05928e754277; domain=.twitter.com; path=/; secure; HttpOnly
< set-cookie: guest_id=v1%3A138574502859327916; Domain=.twitter.com; Path=/; Expires=Sun, 29-Nov-2015 17:10:28 UTC
< status: 401 Unauthorized
< vary: Accept-Encoding
< x-frame-options: SAMEORIGIN
< x-mid: 6a66f617778e5cc014e432a7ec7228027a61baca
< x-runtime: 0.01191
< x-transaction: 4516e92fc449126d
< x-ua-compatible: IE=10,chrome=1
< x-xss-protection: 1; mode=block
<
* Connection #0 to host api.twitter.com left intact
* Closing connection #0
Failed to validate oauth signature and token

最佳答案

希望不大,但是您的时钟设置正确吗? Twitter 只允许请求 header 和他们的时钟之间存在大约 5 分钟的差异。本周早些时候,这完全让我恼火,而且这并不是最好的记录。

埋在这个线程中:

https://dev.twitter.com/discussions/15112

在 Taylor Singletary(在 Twitter 工作)的帖子的四分之一/三分之一处说:

“...查看您的时间戳,看起来您可能比我们的服务器早几分钟。这可能是您遇到的问题。”

关于curl - 获取 401 未经授权 : "Failed to validate oauth signature and token" when running cURL command produced by oauth tool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20290715/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com