0
votes

Request OAuth (when twitter button cliked)

final String TW_CALLBACK_URL_STRING = "http://test.com/callback";

final Uri TW_CALLBACK_URI = Uri.parse(TW_CALLBACK_URL_STRING);

twitter4j.auth.RequestToken twRequestToken = 
                        twitter.getOAuthRequestToken(TW_CALLBACK_URI.toString());

Intent intent = new Intent(Intent.ACTION_VIEW, 
                        Uri.parse(twRequestToken.getAuthorizationURL()));
activity.startActivityForResult(intent, TWITTER_REQUEST_CODE);

Manifest

    <activity android:name=".TwitterLinkActivity" >
        <intent-filter>            
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <data
                android:scheme="http"
                android:host="test.com" />

            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>

Twitter Developer App Settings

enter image description here


Clicking twitter button on my app, Web Browser (chrome android) is opened.

And I log in twitter account and click "accept app" button ("애플리케이션 승인" in below image, UZTest is my test twitter app name.) I am not native English speaker. So I do not know exactly words in English...

enter image description here

I think browser link to http://test.com/callback?~~~~. And My app catch this url, and start activity.

But my app can not... It just link http://www.test.com in chrome android browser.

I tried change callback url = "myapp://test.com", but only http(or https) is only available. (Twitter Developer)

How can I receive oauth token?

1

1 Answers

1
votes

I did sovle it!

Below two value is not same value (?)

  1. final String TW_CALLBACK_URL_STRING = "http://test.com/callback";

  2. Callback URL: http://test.com/callback (OAuth Setting in Twitter Developer)

1 is only use my app. So I change to "myscheme://myhost" in java code and manifest file.

2 is not oauth request callback url (I do not know exactly what.)

Then It works fine.