Oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match


#1

I am using the following libraries for Android-Twitter integration
signpost-commonshttp4-1.2.1.1.jar
signpost-core-1.2.1.1.jar
twitter4j-core-2.1.11.jar

The error message is same as indicated at the beginning of the thread

“oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.”


#2

See [node:204] for some tips on troubleshooting OAuth.


#3

Please verify whether the device DATE and TIME are up to date. If not, then it might cause problems with the access token.


#4

Here below is the error message.

Error during OAUth retreive request token
oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.

Please HELP!!!


#5

I am also having the same error. Please help


#6

change the callback url to ‘oob’

final String url = provider.retrieveRequestToken(consumer, “oob”);

This is happening because ur app type is desktop

i saw the same error


#7

I am also having the same error. Check with setting device date and call back url also but not working.
My app is working on some devices and gives problem on Samsung galaxy ace. And gives error:
oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
But If Consumer key is not correct then why it is working on other devices. Not getting
this… Below is my code where i get this exception.
String url = “”;
try {
url = provider.retrieveRequestToken(consumer,
OAUTH_CALLBACK_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_NO_HISTORY
| Intent.FLAG_FROM_BACKGROUND);
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
Log.e(Common.TAG, “Error during OAUth retrieve request token”+ e);
}
return url;
}
I am using following libs.

  1. signpost-commonshttp4-1.2.1.1.jar
  2. signpost-core-1.2.1.1.jar
  3. signpost-jetty6-1.2.1.1.jar
  4. twitter4j-core-2.1.11.jar

#8

me too


#9

My app throwing this error " Error during OAUth retrieve request token"… what will be the solution… help


#10

You can resolve like

  1. In your twitter application settings [in twitter page: https://dev.twitter.com/apps], make sure you make the application Read & Write
  2. Also, fill the call back URL and do not leave it blank.

#11

I’m getting the same thing using signpost on Android devices. It was working fine but has stopped recently. We attempt to get permission to tweet, user can choose between Browser and Twitter app; select browser and login, and it works; but select Twitter app and the request fails.

I’ve checked all of the things mentioned: date and time, read/write, and none are the problem.
Has this issue been addressed since the previous posts?


#12

Mention a Callback URL at https://dev.twitter.com/apps/
Mention the same callbackURL in ur android app like
provider.retrieveRequestToken(consumer, Constants.OAUTH_CALLBACK_URL);

It worked for me…


#13

It worked for me.
By making sure that we added a valid callback url in our app setting .


#14

like what?


#15

thanks a lot dude… nice fix :stuck_out_tongue: its worked for me…


#16

It works on localhost and doesn’t on remote server… 401 error… i checked time, i did everything. i hate twitter for this error


#17

I spent hours trying to figure this out and there was very little help from either twitter or signpost or fixes in various posts. What worked for me is replacing signpost with the Oauth implemntation in Twitter4j:

TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("XXXX", "YYYY");

instead of signpost:

     OAuthConsumer consumer = new DefaultOAuthConsumer("XXXX", "YYYYY");

     OAuthProvider provider = new DefaultOAuthProvider(
            "https://api.twitter.com/oauth/request_token",
            "https://api.twitter.com/oauth/access_token",
            "https://api.twitter.com/oauth/authorize");

#18

I had the same problem. I had set everything as said here… and nothing. Then i went to twitter site and refreshed the API keys and then it worked.

Hope it helps someone


#19

uffff its happening to me again, since the API changed!!!

did anyone solve this? any idea? or tutorial about oAuth?

mine was working fine up to the new API change… :frowning:


#20

and again… and again

This time the app was working, even tweeting… and stopped working, throwing that exception… WHY??? any ideas?