我正在尝试提出一个 POST 请求以通过 RestClient 在轨道中生成持有者令牌,但将 403 禁止作为状态代码


require 'base64'
require 'rest-client'
require 'json'
key="**************************"
secret="****************************************"
str="#{key}"+":"+"#{secret}"
encoded_str= Base64.encode64(str).delete("n")
encoded_str = "Basic "+"#{encoded_str}"
response=RestClient::Request.execute(method: :post, url: https://api.twitter.com/oauth2/token', headers: {'Authorization': encoded_str, 'Content-Type': "application/x-www-form-urlencoded;charset=UTF-8"},body: {'grant_type': "client_credentials"})
puts response.code

使用者密钥和机密正确

encoded_str是正确的,通过邮递员验证。

实际上,Twitter确实对你可以协商代币的次数有一些限制 - 它有助于阻止这种形式的身份验证的广泛分布的客户端用例。您需要详细检查文档以了解速率限制。

相关内容

最新更新