Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API not accepting callback URL for Android App

I downloaded the OAuthDemo Android App from www.marakana.com. It works fine with their included key/secret & callback url. I read up on twitter OAuth API and registered a Browser type app for my Android code and set the callback url to www.mysite.com, read & write general access and got my key/secret.

However when i replace the key/secret from the original OAuthDemo with mine, I get an Authentication error:

05-27 14:40:25.964: WARN/System.err(441):     oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.twitter.com/oauth/request_token
05-27 14:40:25.974: WARN/System.err(441):     at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
05-27 14:40:25.974: WARN/System.err(441):     at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
05-27 14:40:25.974: WARN/System.err(441):     at com.marakana.oauth.MainActivity$OAuthAuthorizeTask.doInBackground(MainActivity.java:116)
05-27 14:40:25.974: WARN/System.err(441):     at com.marakana.oauth.MainActivity$OAuthAuthorizeTask.doInBackground(MainActivity.java:1)
05-27 14:40:25.974: WARN/System.err(441):     at android.os.AsyncTask$2.call(AsyncTask.java:252)
05-27 14:40:25.974: WARN/System.err(441):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
05-27 14:40:25.974: WARN/System.err(441):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
05-27 14:40:25.974: WARN/System.err(441):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
05-27 14:40:25.974: WARN/System.err(441):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
05-27 14:40:25.974: WARN/System.err(441):     at java.lang.Thread.run(Thread.java:1020)
05-27 14:40:25.984: WARN/System.err(441): Caused by: java.io.FileNotFoundException: https://api.twitter.com/oauth/request_token
05-27 14:40:25.984: WARN/System.err(441):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:532)
05-27 14:40:25.984: WARN/System.err(441):     at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:283)
05-27 14:40:25.984: WARN/System.err(441):     at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getContent(HttpURLConnectionResponseAdapter.java:18)
05-27 14:40:25.984: WARN/System.err(441):     at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:228)
05-27 14:40:25.984: WARN/System.err(441):     at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
05-27 14:40:25.984: WARN/System.err(441):     ... 9 more
05-27 14:40:29.113: WARN/InputManagerService(73): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@408df318 (uid=10035 pid=441)
05-27 14:40:29.133: WARN/IInputConnectionWrapper(441): showStatusIcon on inactive InputConnection

The code is located here...https://gist.github.com/996219

I found these relevant questions in Stackoverflow.com: 1. OAuth + Twitter on Android: Callback fails 2. oauth_callback on Android

and got to this point where:

Does this mean I can enter a callback url: www.mysite.com in the dev.twitter.com site and then in my android code enter an oauth_callback_url = "myappname";

Im using jtwitter which requires a scheme which forms part of the url. How should that look like? I tried:

private static final String OAUTH_CALLBACK_URL = "http://www.santiapps.com";
private static final String OAUTH_CALLBACK_SCHEME = OAUTH_CALLBACK_URL + "://callback";

but that didn't work either. Pls help me understand where I am doing wrong?

like image 239
marciokoko Avatar asked May 28 '11 17:05

marciokoko


People also ask

How do I add a callback URL to twitter?

Enable 3rd Party Application in TwitterClick "App Settings". Scroll down to your app and click the settings (cog) icon. Scroll down to "Authentication settings" and click "Edit". Toggle "Enable 3-legged OAuth" to be on, and we'll need to fill in two properties, Callback URLs and Website URL .

What is callback URI twitter?

As users work through these flows, they need a web page or location to be sent to after they have successfully logged in and provided authorization to the developer's App. This follow-up webpage or location is called a callback URL.

What is callback URL in API?

Basically, a callback URL is the home destination after a script of executable code links two different functions or programs.


1 Answers

I had this same problem. I did a packet capture since I knew the URL was good. The response from the server was:

<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <error>Desktop applications only support the oauth_callback value 'oob'</error>
  <request>/oauth/request_token</request>
</hash>

For me the problem was application type in the Twitter application settings needed to be set to "Browser". Problem was that twitter changed their interface and removed the application type. You need to specify a callback URL in the application settings page to implicitly switch it to Browser type.

  • http://groups.google.com/group/twitter-development-talk/browse_thread/thread/0f744fe83fd9ef90?pli=1
  • https://dev.twitter.com/discussions/282
like image 199
Shawn Avatar answered Sep 19 '22 13:09

Shawn