I am trying the following sample app for twitter oauth.
http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html
private void askOAuth() {
try {
consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
provider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token",
"http://twitter.com/oauth/access_token",
"http://twitter.com/oauth/authorize");
String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
} catch (Exception e) {
Log.e(APP, e.getMessage());
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
When i run the following code it gives exception as following
"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."
on this line String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
I provided the correct 'key' and 'secret' does twitter giving me wrong key and secret ?
I have spent several hours on this. Seems that you have to set ANY value to the callback url in the Settings tab in your Twitter application developer panel. Keeping the default empty value disables dynamic callback urls.
All the tutorials and all the information I have found online is just void. Twitter long removed the "Client / Website" radio button.
Moreover, OAuth checks for clock skews.
I just had the same problem. It only appeared on my dev phone, but on the emulator and another phone the code worked fine. After trying out several solutions to related questions with no luck, eventually it turned out that I had not set the time and date on the dev phone, which doesn't have a sim-card in it. This caused SSL certificates to be invalid and OAuth request to fail, as well as anything else that used HTTPS. After setting the time the problems went away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With