[英]HTTParty for Twitter, fails to authenticate when params included
I'm trying to use the verify_credentials endpoint from the Twitter API. 我正在尝试使用Twitter API中的verify_credentials端点 。 I want to set the
include_entities
param to false
. 我想将
include_entities
参数设置为false
。 I'm able to authenticate with the first example (so I know my oauth_options
value is correct), but if I try to set the include_entities param, I get this error {"code"=>32, "message"=>"Could not authenticate you."}
. 我可以通过第一个示例进行身份验证(因此我知道我的
oauth_options
值正确),但是如果尝试设置include_entities参数,则会收到此错误{"code"=>32, "message"=>"Could not authenticate you."}
。 Note: I cannot use the Twitter gem. 注意:我不能使用Twitter gem。
WORKS: 作品:
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json", headers: {"Authorization" => oauth_options})
DOES NOT WORK: 不起作用:
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json", headers: {"Authorization" => oauth_options}, query: {include_entities: false})
ALSO DOES NOT WORK 也行不通
response = HTTParty.get("https://api.twitter.com/1.1/account/verify_credentials.json?include_entities=false", headers: {"Authorization" => oauth_options})
Make sure you adjust the logic for computing the Authorization token, as it will need to consider query params. 确保调整用于计算授权令牌的逻辑,因为它将需要考虑查询参数。
Read the documentation here https://dev.twitter.com/oauth/overview/authorizing-requests or use a library that takes care of it automatically. 在此处阅读文档https://dev.twitter.com/oauth/overview/authorizing-requests或使用自动处理它的库。
I can confirm it works if you sign the request correctly 如果您正确签署请求,我可以确认它是否有效
$ oksocial 'https://api.twitter.com/1.1/account/verify_credentials.json?include_entities=false' | jq .
{
"id": 111,
"id_str": "111",
"name": "Fred Blogs",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.