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?
Maybe the following example will be of any help:
https://github.com/ddewaele/AndroidOAuthFlowSample/tree/latitude_branch
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With