4

Hello im tryin to use Twitter with OAuth but i receive this exception

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

im using this sample http://code.google.com/p/oauth-signpost/wiki/TwitterAndSignpost

Error Line: String authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);

  • Is this when you do your initial request for the request_token? Can you post what your request looks like? Or even the base string if you can. – xil3 Jul 08 '10 at 17:13
  • 1
    hi xil3 it happens on this line String authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND); –  Jul 08 '10 at 17:30
  • I can't understand it worked yesterday –  Jul 08 '10 at 20:33

3 Answers3

7

this will not happen only for this reason ::

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

another reason is ::

your Device date and time are incorrect.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • I don't understand the message said "Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match." it works, than you –  Jul 17 '10 at 19:06
  • 1
    Jorgesys - brilliant observation. I wish I could vote up this answer 100 times. – Abhijit Feb 10 '12 at 17:47
  • 2
    @Jorgesys I have check with changing my device date but it's 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.... – Vikram Apr 03 '12 at 11:39
  • The error description "This can happen if the consumer key was not correct or the signatures did not match." is a general description for several reasons, very strange if it works on other device, if you print the device´s date are you sure it is correct? – Jorgesys Apr 03 '12 at 22:07
2

You have to enable Callback URL on Twitter app settings (https://apps.twitter.com/app/123456/settings)

type into Callback URL: http://www.google.com /whatever/

And tada!

xnagyg
  • 4,784
  • 2
  • 32
  • 24
-1

i have the same error same consumer Key and secreat key is working in iphone but when i set this to my android app it dispaly this error message. Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.

Megha
  • 1,581
  • 2
  • 18
  • 33