简体   繁体   English

Yahoo BOSS API的OAuth问题

[英]OAuth issue with the Yahoo BOSS API

I'm trying to call the Yahoo BOSS API with some query strings as detailed here . 我正在尝试使用一些查询字符串来调用Yahoo BOSS API,如此处所述 Things work fine unless there's a space in the query. 除非查询中没有空格,否则一切工作正常。 I'm encoding the query string using URLEncoder.encode(q, "UTF-8") . 我正在使用URLEncoder.encode(q, "UTF-8")对查询字符串进行编码。

But as soon as there's a white space in the query string, the request fails with a Please provide valid credentials. OAuth oauth_problem="signature_invalid" 但是,只要查询字符串中有空格,请求就会失败,并显示“ Please provide valid credentials. OAuth oauth_problem="signature_invalid" Please provide valid credentials. OAuth oauth_problem="signature_invalid" error. Please provide valid credentials. OAuth oauth_problem="signature_invalid"错误。 Since the query string is encoded, the white space should be escaped, has anyone else faced and solved this issue before? 由于查询字符串是经过编码的,因此应该对空格进行转义,其他人之前是否曾遇到并解决过此问题?

You need to get the credentials ie Customer key and Customer Secret from the authorized person on yahoo's end. 您需要从yahoo的授权人员那里获取凭据,即“客户密钥”和“客户机密”。 Once you get it, you can replace those in the code and will then would be authorized. 一旦获得,您可以替换代码中的代码,然后将被授权。

I had the exact same problem. 我有同样的问题。 You need to use: 您需要使用:

UrlEncoder.encode(q,"UTF-8").replace("+","%20")

Your version is breaking your signature because Oauth uses percent encoding to sign the request. 您的版本破坏了您的签名,因为Oauth使用百分比编码来签署请求。 So you'll need the %20 . 因此,您需要%20 A good article on that topic can be found here . 可以在这里找到有关该主题的好文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM