How to get twitter oauth callback url returned to activity (on Android)?

2,725 views
Skip to first unread message

Mathias Lin

unread,
Dec 13, 2010, 8:27:19 PM12/13/10
to Twitter Development Talk
How to get twitter oauth callback url returned to activity (on
Android) when it's a callback url starting with http - or
alternatively: how to register a callback url that doesn't start with
http?

I want to use signpost/OAuth with Twitter in my native Android app so
that I have an activity handling the callback url (and user doesn't
need to enter the pin or the pin doesn't need to be screen scraped). I
found many posts with samples like:

Oauth Callback not found after allowing the app on Twitter.

http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/#idc-cover

http://code.google.com/p/agirardello/

and they all use a callback url that doesn't start with http. For
example:

<data android:scheme="myapp" android:host="twitt"></data>
But how to register a callback url in the twitter app settings? I'm
always getting 'invalid url format' when submitting the app settings
form.

I suppose, since I am in the browser already when the twitter site
calls the callback url, I cannot just use http as the scheme (I tried
to use http://www.mydomain.com and set http as the scheme and www.mydomain.com
as the host). At least in my test, I won't be redirected to the app
but remain in the browser and the callback url is opened in the
browser. (I also cleared the defaults of the browser app before.)

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

Taylor Singletary

unread,
Dec 14, 2010, 10:03:37 AM12/14/10
to twitter-deve...@googlegroups.com
Consider the oauth callback that you set in your application record as not much more than a placeholder. In OAuth 1.0A, it is required to send the oauth_callback you want to use explicitly on the request token step -- so regardless of what you set on dev.twitter.com, you still have to provide a URL during the OAuth sequence.

While the UI on dev.twitter.com will not allow custom URI schemes, the request token step will. So, put a placeholder in on your application record, preferably pointing to a website representing your application, and explicitly declare your custom callback on the request token step.

Taylor


--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk

Reply all
Reply to author
Forward
0 new messages