MAking API request always got "token_rejected" 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
PIaUYF1L9CFtG2Zj1HkyhgzT开发者_运维问答cYbJZemoxO3WtOD8PHM3cUGJWvGcAibfDf1Ntu6BmsQa_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.
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.
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.
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
精彩评论