Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a production quality OAuth sample for Android?

There are plenty of samples out there, especially for Twitter. This one seems to be one of the most complete so I've been hacking on it:

https://github.com/brione/Brion-Learns-OAuth

However, all of the samples are basically proof of concept code. They all have rough edges like leaving a split task stack when you launch through the browser. I've got the app I'm playing with working mostly the way I want it to by declaring it singleTask and forcing the browser to call back into the original task instead of starting up a new activity:

<activity android:name=".MainActivity"
              android:label="@string/app_name"
              android:launchMode="singleTask">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

However I'm wondering if there are better ways to handle this, like popping up a modal WebView to take the user through the auth process?

I'm assuming that for Twitter in particular the "right" thing to do is probably to swap to xauth. But I still would like to know, generally speaking, is there a best-practice production quality OAuth implementation for Android out there?

like image 412
mikerowehl Avatar asked Dec 31 '25 07:12

mikerowehl


2 Answers

Maybe the following example will be of any help:

https://github.com/ddewaele/AndroidOAuthFlowSample/tree/latitude_branch

like image 125
tamsler Avatar answered Jan 01 '26 21:01

tamsler


Been there, done that. The android examples floating around are almost always miss some important detail or are simply not up to date. That's why I wrote an easy to follow summary how I did OAuth on android a few days ago:

http://nilvec.com/implementing-client-side-oauth-on-android/

I can also publish the OAuth helper class I implemented if anyone's interested.

like image 28
ldx Avatar answered Jan 01 '26 20:01

ldx