Integrating Google Drive in Play Scala application with Google+ API


In our earlier blog, i.e., Integrating Google Drive infrastructure in Play Scala application we talked about integrating the Google Drive infrastructure in Play Scala application as like Assembla and some others. In that blog we used OAuth2 in order to communicate with the Google using Access Token and Refresh Token.

For getting the Access Token & Refresh Token we used following Scopes of Google API:

"https://www.googleapis.com/auth/userinfo.email"
"https://www.googleapis.com/auth/userinfo.profile"

But now Google API has deprecated these scopes, and Google will shut down the support for these scopes on September 1, 2014. For further information on Google API’s new Scopes click here.

So for integrating Google Drive API with new scopes of Google+, just make following changes.

1. Go to the Google Developers Console, & find the Google+ API in the APIs & auth section (given in the sidebar on the left) and set its status to ON.

2. Then prepare the browser request URL with Google+ scopes, in order to get the authorization code.

val redirectURI = "http://localhost:9000/driveAuth"

 def authenticateToGoogle = Action { implicit request =>
 val urlToRedirect = new GoogleBrowserClientRequestUrl("Client ID", redirectURI, Arrays.asList("https://www.googleapis.com/auth/plus.login", "https://www.googleapis.com/auth/drive")).set("access_type", "offline").set("response_type", "code").build()
 Redirect(urlToRedirect)
 }

The only change we have made in above code is the:

Scope - https://www.googleapis.com/auth/plus.login

Rest everything remains same.

3. When the users will hit this url , they’ll be asked to Log in and allowing the application to access of their Google Drive’s documents and the other basic information. New scope will ask for User’s profile, & the list of circled people that the user has granted your app access to know.

4. Now follow from step-3 given in here.

So, we see that it is quite easy to upgrade to new Google+ scopes.

This entry was posted in Agile, Play Framework, Reactive, Scala, Web and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s