|In this article, I’m going to show you how you can use Foursquare in your Android application using OAuth 2.0.
We’ll be using
I’ve decided to use the foursquare-api-java, a project hosted at Google Code, as it offers a rich interface to interact with Foursquare. The same API calls are possible through the Google API client for Java, but it would require you to write your own model classes to do the JSON to Java translation.
In the sample application hosted at Github, we’re going to display a map where the user can select a location. Upon selecting a location, we’ll load up a list of Foursquare venues that the user can select.
|A couple of months ago, I published a post entitled A 30 minute guide to integrating Twitter in your Android application.. The post presented a sample Android application to integrate Twitter. Using the signpost library, the user was able to authorize our application to send tweets on his/her behalf. It seems that everyone is migrating to Oauth 2.0, but Twitter is still stuck at OAuth 1.0. Nevertheless, I still wanted to update the sample we did a couple of months ago for 3 reasons :|
|Today we’ll be looking at the Google APIs Client Library for Java. The API is provided by Google, and is a flexible, efficient, and powerful Java client library for accessing any HTTP-based API’s on the web. According to Google, it is the recommended library for accessing Google API’s based on REST or JSON-RPC. One of the nice things about this library is that it fully supports the Android environment out of the box. So we’ll focus on those features in this article.|
To avoid confusion, Google offers the following APIs (the first one being the topic of this post, and compatible with the Android platform) :
- Google APIs Client Library for Java (google-api-java-client)
- Google Data Java Client Library (gdata-java-client)
Unfortunately, there are no samples available that perform the OAuth dance in Android using this library, so I thought I’d write one myself. The code for this article can be found in the AndroidOauthGoogleApiJavaClient repository
Continue reading “OAuth in Android using the Google APIs Client Library for Java” »