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?
even i had the same problem but i solved it by adding "https://www.google.com" to the CALLBACK_URL field while registering my application with twitter. Actually i think that providing a valid-url makes the application browser-app else it remains a desktop-app...
It seems the problem was that I had my app configured as Client and it had to be Browser type even though its a native client app on android.
callback to another site must be specified at the time registering your twitter application( in callback (Browser Type) ) , and callback in your code must me same as u specified in the manifest file, under tag..
I had this same problem. I did a packet capture since I knew the URL was good. The response from the server was:
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.