Android Twitter4j getOAuthAccessToken exception


#1

Hello.

I’m having strange behavior when trying to login to Twitter with my application.

If i’m logging for a first time I had to enter Login Password and then press “Sign In” button. In this scenario I have exception during call getOAuthAccessToken(requestToken, verifier) function.

Then I’m trying to login for a second and all futher times. This time on twitter login page I’m logged in (no password and login editors) and I have to only press “Sign In” button. In this scenario everything is going ok. Function getOAuthAccessToken returns me an accesToken.

The same code works first and second time, but have diffrent behaviors. This is very strange.

questions:

  1. can it be not my fault?
  2. how to fix it if it is my fault?
  3. is there a way to debug twitter4j lib conversation with twitter API?

Finaly my code:
first. I get requestToken and start browser intent

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
Configuration configuration = builder.build();

TwitterFactory factory = new TwitterFactory(configuration);
twitter = factory.getInstance();

try {
requestToken = twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);
this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL())));
} catch()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

second. I receive notification from browser intent

Uri uri = getIntent().getData();
if (uri.toString().startsWith(TWITTER_CALLBACK_URL)) {
String verifier = uri.getQueryParameter(URL_TWITTER_OAUTH_VERIFIER);
try {
AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);
} catch()

there I have an exception if i was not logged in.

“No authentication challenges found
Relevant discussions can be found on the Internet at:
http://www.google.co.jp/search?q=9ddbeb3a or
http://www.google.co.jp/search?q=937eec8d
TwitterException{exceptionCode=[9ddbeb3a-937eec8d c8a7b39b-dc5ea0d9], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.5}”

Link to full sample app code: https://www.dropbox.com/s/zhpq7j7mnwygklx/AndroidTwitterConnect_1.zip