Google Play services v1.0 with Google+ APIs and OAuth 2.0 Functionality Rolling Out

Google Play services should arrive virtually on all Android 2.2+ devices with the Google Play Store in the very near future. Google Play services announced in June at Google I/O, is a new development platform for developers who want to integrate Google services into their apps. The v1.0 rolling today, includes Google+ APIs and new […]

Google Play services v1.0 with Google+ APIs and OAuth 2.0 Functionality Rolling Out to all Android 2.2+ devices

Google Play services should arrive virtually on all Android 2.2+ devices with the Google Play Store in the very near future.

Google Play services announced in June at Google I/O, is a new development platform for developers who want to integrate Google services into their apps. The v1.0 rolling today, includes Google+ APIs and new OAuth 2.0 functionality.

At that point, "all those devices will have new tools for working with OAuth 2.0 tokens," Google posted.

Why OAuth 2.0 Matters? Google Play services make OAuth 2.0 authorization available to Android apps that want to access Google APIs, with a good user experience and security.

After the Google Play services rollout is complete, it will only be available on compatible Android devices running 2.2 or later. It is also possible for a user to choose to disable the software. For these reasons, "before you can start making calls, you have to verify that Google Play services is installed. To do this, call isGooglePlayServicesAvailable(). The result codes, and how to deal with them, are documented in the ConnectionResult class," Google explains.

Choosing an Account. Now you can use the handy AccountPicker.newChooseAccountIntent() method to give you an Intent; feed it to startActivityForResult() and you'll launch a nice standardized user experience that will return you an account (if the user feels like providing one).

Getting a Token. There's really only one method call you need to use, GoogleAuthUtil.getToken(). It takes three arguments: a Context, an email address, and another string argument called scope. "Every information resource that is willing to talk OAuth 2.0 needs to publish which scope (or scopes) it uses. For example, to access the Google+ API, the scope is oauth2:https://www.googleapis.com/auth/plus.me. You can provide multiple space-separated scopes in one call and get a token that provides access to all of them," explains Android team.

Registering Your App. "You need to visit the Google APIs Console, create a project, pick the APIs you want to access off the Services menu, and then hit the API Access tab to do the registration. It'll want you to enter your package name; the value of the package attribute of the manifest element in your AndroidManifest.xml."

In the mean time, go grab the client library from Android SDK manager, check out updated documentation, and start coding!

https://developers.google.com/android/google-play-services
https://developers.google.com/+/mobile/android/#getting_started