Google Plus for Grails

Vishal-Sahu edited this page Apr 16, 2012 · 9 revisions
Clone this wiki locally

The Google Plus Plugin for Grails provides utilities that provide a more rich and coherent experience while interacting with the Google Plus API. Using this plugin to access the Google Plus API you get Custom Built and highly enriched Objects as compared to the traditional Google Plus API calls than return some JSON content.

Features

The plugin provides 2 core features to the developer

  1. It allows you to generate an Access Token that is required for accessing the Google Plus API
  2. It provides Highly Enriched Objects as compared to traditional JSON content when accessing the API directly.

Usage

Configure these plugin attributes in Config.groovy

grails.plugins.googlePlus.clientId='<xxx-Your-clientID-xxx>'
grails.plugins.googlePlus.clientSecret='<client secret>>'
grails.plugins.googlePlus.scope='<https://www.googleapis.com/auth/plus.me\>'
grails.plugins.googlePlus.callBackController='<yourController>'
grails.plugins.googlePlus.callBackAction='<yourAction>'

First register your Application at https://code.google.com/apis/console

1) Generating an Access Token

First redirect the user to Google Server with required permissions(scope) using the Url generated by the method
googlePlusService.getAuthorizationUrl()

This method call utilizes variables defined in your Config.groovy

grails.plugins.googlePlus.clientId grails.plugins.googlePlus.clientSecret grails.plugins.googlePlus.scope

This would generate a code that is further processed to give you an Access Token. The access token can then be accessed anytime via a call to the method
googlePlusService.getAccessToken()

Once the access token has been received, a callback action and controller is required to send the request back to the application. These values are provided via the below config variables

grails.plugins.googlePlus.callBackController grails.plugins.googlePlus.callBackAction

  1. Google Plus Api Calls

Calls to the Google Plus API via this plugin would return Groovy Objects corresponding to the data queried. For example googlePlusServie.getCurrentProfile() would give you a Groovy Object of class Person containing info about that person.