Orkun
Orkun

Reputation: 7228

Oauth Callback not found after allowing the app on Twitter

Hey. I am developing an application using the Twitter4j api. In order to allow the application and get an access token, I launch the browser with the callback parameters which I had set in the manifest file.

<data android:scheme="scheme" android:host="authenticatorapp"></data> 

After allowing the application, the browser calls the following and fails with a not found message. scheme://authenticatorapp?oauth_token=n5vd99dfnmnf...

I tried it both on the emulator and the device. In the emulator, LogCat gives me this :

12-12 15:04:05.743: ERROR/browser(230): onReceivedError -10 scheme://authenticatorapp?oauth_token=Jj...M&oauth_verifier=3ZfuY... The protocol is not supported.

-- The manifest file :

    <activity android:name=".AuthenticatorApp"
        android:launchMode="singleInstance"
        >
        <intent-filter>         
            <category android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.LAUNCHER" />
            <data android:scheme="scheme" android:host="authenticatorapp"></data>                                
        </intent-filter>            
    </activity>

    <!-- Broadcast Receiver that will process AppWidget updates -->
    <receiver android:name=".ZaytungWidget" android:label="@string/widget_name">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />                             
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/tweet_metadata" />
    </receiver>
    <!-- Service to perform web API queries -->
    <service android:name=".ZaytungWidget$UpdateService" />
</application>

<uses-sdk android:minSdkVersion="4" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.INTERNET" />    

Upvotes: 3

Views: 2166

Answers (3)

iarwain01
iarwain01

Reputation: 424

This is what I have in my working Manifest.xml, where org.gpsagenda.OAUTH is the activity doing the Authenticating.

        <activity android:name="org.gpsagenda.OAUTH" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.DEFAULT"></category>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <data android:scheme="gpsagenda" android:host="twitt" />
        </intent-filter>
    </activity>

Upvotes: 1

Luke Dunstan
Luke Dunstan

Reputation: 4882

Can you please post the whole manifest file?

I found the following question which may be useful later on: OAuth instance state in Android

The question linked to the following example application, which may be helpful:

http://code.google.com/p/jpoco/source/browse/trunk/jpoco-android-app/AndroidManifest.xml

Upvotes: 3

Mathias Conradt
Mathias Conradt

Reputation: 28665

If you're developing a native app, you don't use the callback parameters, but need to let the user enter the pin in your app somewhere - which he gets when you open the authorization_url in a browser or probably more comfortably within your app in a webview.

You could also automatically fetch the pin after the user has clicked on 'yes' in the authorization twitter webpage, but not sure if it's against the twitter ToS.

Upvotes: 0

Related Questions