I’ve integrated twitter4j into an android app and for the most part it works seamlessly but I have noticed a sporadic issue that occurs when attempting to authenticate with twitter when the user has indicated to have their login credentials to twitter saved in the browser. After the call to getOAuthRequestToken(callbackURL) is made, the android browser is opened as usual, but then the browser pops up an error page like:
Web page not available
The web page at https://api.twitter.comtwitter-callback-uri:///?oath_token=.....................
So, it looks like what is happening is the browser is being redirected to an invalid url. I think the redirect should just look like this: twitter-callback-uri:///?oath_token=……………
To provide more info, the request for the token looks like this:
rToken = twit.getOAuthRequestToken("twitter-callback-uri:///");
And an intent filter was added to the android manifest to recognize this uri. The intent filter looks like this:
<activity android:name=".LoginActivity"
android:screenOrientation="unspecified"
android:finishOnTaskLaunch="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="twitter-callback-uri"/>
</intent-filter>
</activity>
This typically works, the only problem seems to be if the user’s twitter login credentials are saved in the browser.
I’m having the same problem as you. I found your question after asking mine 🙂
Take a look at this
Twitter API returns invalid callback – Cannot authorize
Specifically, look at the code snippet in my question.