I develop android application that backup photos to flickr.
I had the next problem several times:
Sometimes I receive 401 response ("Response Code: 401, Response Message:
Unauthorized, Error: oauth_problem=token_rejected") instead of response
with access token, during Exchanging the Request Token for an Access Token.
This problems happens mostly when I have bad internet connection (when I am
suing 3g internet).
Here are logs that shows this behavior:
2015-01-07 17:12:00,603 DEBUG [oauth.OAuthInterface]-[122] Getting Request
Token with parameters: <a
href="https://www.flickr.com/services/oauth/request_token">www.flickr.com/servic
es/oauth/request_token</a> [
Parameter [name=oauth_callback, value={MY_APP_NAME}-flickr://callback],
Parameter [name=oauth_consumer_key, value={MY_CONSUMER_KEY}],
Parameter [name=oauth_nonce, value=154099562370628],
Parameter [name=oauth_signature_method, value=HMAC-SHA1],
Parameter [name=oauth_timestamp, value=1420630920],
Parameter [name=oauth_version, value=1.0],
Parameter [name=oauth_signature, value=oVkmG/7nOoiO0P6Dm2j4Aql4lDs=]
]
2015-01-07 17:12:01,695 DEBUG [oauth.OAuthInterface]-[136]
Response: {oauth_token_secret={RESULT_OAUTH_TOKEN_SECRET}, oauth_callback_confirmed=true, oauth_token={RESULT_OAUTH_TOKEN}}
After that I open next url in browser for user:
url = <a href="https://m.flickr.com/services/oauth/authorize?oauth_token="
rel="nofollow">m.flickr.com/services/oauth/authorize?oauth_token=</a>{RESULT_OAU
TH_TOKEN}&perms=write
After authorization I get next callback:
{MY_APP_NAME}-flickr://callback?oauth_token={RESULT_OAUTH_TOKEN}&oauth_verif
ier=59bbeb1cb3ffedca
Using verifier I make next request:
2015-01-07 17:12:47,043 DEBUG [flickrjandroid.REST]-[288] Send Post Input
parameters [
Parameter [name=oauth_consumer_key, value={MY_CONSUMER_KEY}],
Parameter [name=oauth_nonce, value=154146242657849],
Parameter [name=oauth_signature_method, value=HMAC-SHA1],
Parameter [name=oauth_timestamp, value=1420630967],
Parameter [name=oauth_token, value={RESULT_OAUTH_TOKEN}],
Parameter [name=oauth_verifier, value=59bbeb1cb3ffedca],
Parameter [name=oauth_version, value=1.0],
Parameter [name=oauth_signature, value=yZjgD6iKGxn4lzJVuZHnEaqWsHE=]] <a href="https://api.flickr.com:443/services/oauth/access_token" rel="nofollow">api.flickr.com:443/services/oauth/access_token</a>
The response is:
Response Code: 401, Response Message: Unauthorized, Error:
oauth_problem=token_rejected
What can cause the reject of token?
Can I try make another request using same verifier after getting 401 response
or this will also return 401 response?
This problem happens just sometimes, usually during bad internet connection.
For authorization I use flickrj-android-2.1.1