Thursday, May 9, 2013

GTalk on Android using Smack, OAuth and AccountManager

Google finally released an API to authenticate to GTalk using OAuth a few months ago. This is great, but it makes it even harder to use GTalk in your app. However, it obviously increases the usability a thousand times (especially for users with 2-step-authentication enabled) so you should definitely use OAuth if you plan to release an app which uses GTalk.

You can find the full source for a project using these techniques here:, but I also extracted the parts that really matter into a Gist here:

The library used for XMPP connection is a fork of Smack, called aSmack. It's a patched and tweaked version of Smack for Android.

Nice little bonus: you receive a notification for every new mail that ends up in a user's inbox. For more information on how to use that please refer to the code located in this folder:

No comments:

Post a Comment