1
votes

I have an android app that has an activity flow as follows:

1. Go to main activity, click Login button
2. Get redirected to the Twitter OAuth page
3. Have my app handle a URL like the one below:
oauth://com.galebach.Twitter_oAuth?oauth_token=xnpuie0lmqoPCAvdeitL0CTBgHogwj09nlDbATEk&oauth_verifier=dWMekKAb9aig3ja7skuzXY9SOP9QLZlRbJjLW5UOM

My question is, how can I use the token and verifier in that URL to get a Twitter AccessToken? The problem is that while I have the oauth_token, all of the functions for getting access tokens seem to want RequestTokens and a verifier as input, and I don't know how to build a RequestToken out of the raw string in the URI.

2

2 Answers

2
votes

Now is required to use the Oauth_provider parameter, you can do it this way:

public static final String CALLBACK_URI = "http://www.yoururl.com/";

public static final String OAUTH_VERIFIER = "oauth_verifier";

String verifier = null;

if (uri != null && uri.toString().startsWith(Twitter.CALLBACK_URI)) 
verifier = uri.getQueryParameter(Twitter.OAUTH_VERIFIER);

AccessToken at = mTwitter.getOAuthAccessToken(mRequestToken, verifier);

I hope this helps you. Hector

0
votes

You can get Access token this way:

        TwitterUtility twitterUtility = new TwitterUtility("CLIENT_ID","cLIENT_SECRET");
        AccessToken accessToken = twitterUtility.getAccessToken("OAUTH_TOKEN","Oauth_Verifier");

Ouath_token and oauth_verifier can be retrieved from the url itself.