My Android application uses the Java OAuth library, found here for authorization on Twitter. I can get the request token, allow the token and get confirmation, but when the browser tries to return the re-connect URL to my application, it does not use the URL that I provide in the code, but uses the one that I provided when registering with Twitter .
Note:
1. When registering my twitter application, I provided a hypothetical return URL: http://abz.xyc.com and set the type of application as a browser.
2. I provided the callback URL in my "myapp" code and added an intent filter for my activity using the "View" and "Data Schema" categories as "myapp".
3. The URL that is called during authorization contains the callback URL that I specified in the code.
Any idea what I'm doing wrong here?
Relevant Code:
public class FirstActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); OAuthAccessor client = defaultClient(); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(client.consumer.serviceProvider.userAuthorizationURL + "?oauth_token=" + client.requestToken + "&oauth_callback=" + client.consumer.callbackURL)); startActivity(i); } OAuthServiceProvider defaultProvider() { return new OAuthServiceProvider(GeneralRuntimeConstants.request_token_URL, GeneralRuntimeConstants.authorize_url, GeneralRuntimeConstants.access_token_url); } OAuthAccessor defaultClient() { String callbackUrl = "myapp:///"; OAuthServiceProvider provider = defaultProvider(); OAuthConsumer consumer = new OAuthConsumer(callbackUrl, GeneralRuntimeConstants.consumer_key, GeneralRuntimeConstants.consumer_secret, provider); OAuthAccessor accessor = new OAuthAccessor(consumer); OAuthClient client = new OAuthClient(new HttpClient4()); try { client.getRequestToken(accessor); } catch (Exception e) { e.printStackTrace(); } return accessor; } @Override protected void onResume() {
android oauth twitter twitter client
Samuh
source share