MAking API 请求总是收到“token_rejected”错误
我开发了一个OAuth组件,并完成了Yahoo的OAuth流程,得到了oauth_token。
但是,当我对 yahoo API(如联系人或 YQL)进行 API 调用时,我总是收到“Token_Rejected”错误消息。
HTTP 401
签名:6fR3VdygGrRCO+WrS6tlD3hjHMI=
base_string:
GET&http%3A%2F%2Fsocial.yahooapis.com%2Fv1%2Fuser%2FMOMJS2M2KSMQKT2D
Q4O7NS4JFU%2Fprofile%2Fusercard&oauth_consumer_key%3Ddj0yJmk9ZmZzUFVQblZzM1JVJmQ
9WVdrOU9GbFNRMUJuTmpRbWNHbzlOVFUyTWpRNU9EWXkmcz1jb25zdW1lcnNlY3JldCZ4PTJk%26oaut
h_nonce%3D2366072fe9829333b98eb6f2a7539afa%26oauth_signature_method%3DHMAC-SHA1%
26oauth_timestamp%3D1305099596%26oauth_token%3DA%3D4cnEo.njj1_C6XtkvR3o5x3vOYqrN
hHk3sBFh76pPtcKA07WF69OADx8zU7o0dPSRauN77UIBw.5bEk5opw15A8SSemxquErvhhHPuAhtm0SB
UuGBOSMxapwBdU1.E4oeQQMXIvKRFhy81EVbIDclBcxzeG.y.eEUdNFDkp_suVAKko.i6Tazpbfkqa1C
__7BAQO5m74CIsalgwyyI8z99eITPlzq_llb7CZzhoWJTVzVAVH_hoU2jBbjSwP00AGB.ovXqT0Ayf0.
WHG2v7hhFhVh.MEx6H0oa8rgpUSZr68dViiIPLfV6G.fGCF3GSnE4uVNiDWM2.x4Lf37slpGWqmjUTtX
B8UVlTQU0auc_YCbGC9wSiUHePWEhpzkgQ6lf.G0mZ9VJ5I_9jbZzlJD52ffUoMDVs97qEeT4CRRa.0p
hwt1dWx16pV.cmhRXSHUqCkDXVmCGpZI5rXD6fR2QoCoQNOOf6e3rGqaz1cF_kY4BgKfKWVa_RF.peOg
PIaUYF1L9CFtG2Zj1HkyhgzTcYbJZemoxO3WtOD8PHM3cUGJWvGcAibfDf1Ntu6BmsQa_aZfjZ11ou8n
F1kjeFsf9wUpHOvGS_qOtaUT8b5rV8CXd.mcZyLghscWIOy339QjgZ6nz2PVchf2P2Rd0JhbNR_OzHWb
5l9LBBOH9RM5TkHm7N2HSdxaSxSFA6rLU5gguZU7xFEnQ44o7hMCbyfL4SL6VdOz9hIuTjYh8GHHYTM0
iIU.O.Gh_tNPjLVZ8j6T2G2W1L5JgCYz8K_D7bn8EHL9FNwffqZQgmtXqjqpIFATcQ.h.91zP_uc4mij
gzvwnfE8n80N7hZKVA-%26oauth_version%3D1.0
响应:
<?xml version='1.0' encoding='UTF-8'?>
<yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng'
xml:lang='en-US'>
<yahoo:description>Please provide valid credentials. OAuth oauth_problem="toke
n_rejected", realm="yahooapis.com"</yahoo:description>
</yahoo:error>
我非常确定此访问令牌未过期。
如何解决这个问题? 谢谢。
I have developed a OAuth Component, and completed Yahoo's OAuth Process, got oauth_token.
But when I make API call to yahoo API (like contact or YQL), I always get "Token_Rejected" error message.
HTTP 401
Signature: 6fR3VdygGrRCO+WrS6tlD3hjHMI=
base_string:
GET&http%3A%2F%2Fsocial.yahooapis.com%2Fv1%2Fuser%2FMOMJS2M2KSMQKT2D
Q4O7NS4JFU%2Fprofile%2Fusercard&oauth_consumer_key%3Ddj0yJmk9ZmZzUFVQblZzM1JVJmQ
9WVdrOU9GbFNRMUJuTmpRbWNHbzlOVFUyTWpRNU9EWXkmcz1jb25zdW1lcnNlY3JldCZ4PTJk%26oaut
h_nonce%3D2366072fe9829333b98eb6f2a7539afa%26oauth_signature_method%3DHMAC-SHA1%
26oauth_timestamp%3D1305099596%26oauth_token%3DA%3D4cnEo.njj1_C6XtkvR3o5x3vOYqrN
hHk3sBFh76pPtcKA07WF69OADx8zU7o0dPSRauN77UIBw.5bEk5opw15A8SSemxquErvhhHPuAhtm0SB
UuGBOSMxapwBdU1.E4oeQQMXIvKRFhy81EVbIDclBcxzeG.y.eEUdNFDkp_suVAKko.i6Tazpbfkqa1C
__7BAQO5m74CIsalgwyyI8z99eITPlzq_llb7CZzhoWJTVzVAVH_hoU2jBbjSwP00AGB.ovXqT0Ayf0.
WHG2v7hhFhVh.MEx6H0oa8rgpUSZr68dViiIPLfV6G.fGCF3GSnE4uVNiDWM2.x4Lf37slpGWqmjUTtX
B8UVlTQU0auc_YCbGC9wSiUHePWEhpzkgQ6lf.G0mZ9VJ5I_9jbZzlJD52ffUoMDVs97qEeT4CRRa.0p
hwt1dWx16pV.cmhRXSHUqCkDXVmCGpZI5rXD6fR2QoCoQNOOf6e3rGqaz1cF_kY4BgKfKWVa_RF.peOg
PIaUYF1L9CFtG2Zj1HkyhgzTcYbJZemoxO3WtOD8PHM3cUGJWvGcAibfDf1Ntu6BmsQa_aZfjZ11ou8n
F1kjeFsf9wUpHOvGS_qOtaUT8b5rV8CXd.mcZyLghscWIOy339QjgZ6nz2PVchf2P2Rd0JhbNR_OzHWb
5l9LBBOH9RM5TkHm7N2HSdxaSxSFA6rLU5gguZU7xFEnQ44o7hMCbyfL4SL6VdOz9hIuTjYh8GHHYTM0
iIU.O.Gh_tNPjLVZ8j6T2G2W1L5JgCYz8K_D7bn8EHL9FNwffqZQgmtXqjqpIFATcQ.h.91zP_uc4mij
gzvwnfE8n80N7hZKVA-%26oauth_version%3D1.0
Response:
<?xml version='1.0' encoding='UTF-8'?>
<yahoo:error xmlns:yahoo='http://yahooapis.com/v1/base.rng'
xml:lang='en-US'>
<yahoo:description>Please provide valid credentials. OAuth oauth_problem="toke
n_rejected", realm="yahooapis.com"</yahoo:description>
</yahoo:error>
I am very sure this access token is not expired.
How to resolve this problem?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经解决了这个问题,原因是我错过了查询字符串,当我将查询字符串编码为基本字符串时,这个问题已经解决了。
I had resolved this question, the reason is I missed query string, when I encoded query string into base string, this issue had been solved.
对于将来遇到此问题的任何人:如果您不断从 https 收到“令牌被拒绝”: //api.login.yahoo.com/oauth/v2/get_token 使用 PHP。然后,如果与您的流程相关,请确保您在进行此调用之前对访问令牌调用 urldecode。
For anyone coming across this question in the future: If you keep getting "token rejected" from https://api.login.yahoo.com/oauth/v2/get_token using PHP. Then make sure, if relevant to your flow, that you are calling urldecode on the access token prior to making this call.
如果您将访问令牌存储在表中,然后使用该表中的访问令牌调用 API,并且将该列设置为字符串,则该令牌将缩短为 255 个字符。我只是将其从字符串更改为文本并存储它。
当然,如果您将访问令牌存储在表中然后进行调用,则情况如此。当我修复它后,我收到了完全相同的错误消息。
希望我能帮忙,
戈兰
If you're storing the access token in a table, and then calling the API using the access token from that table, it will get shortened to 255 characters if you made the column a string. I just changed it from a string to a text and stored it.
This is of course if you are storing the access token in a table and then making the call. I had this exact same error message, once I fixed that it worked.
Hope I could help,
Goran