Google for Spring Security OAuth plugin

1 vote
Dependency:
compile ":spring-security-oauth-google:0.3.1"

 Documentation  Source  Issues

Summary

Installation

Add the following to your grails-app/conf/BuildConfig
…
plugins {
…
	compile ':spring-security-oauth-google:0.1'
…
}

Description

Add to your Config:

for Google OAuth 1.0

oauth {
  …
  providers {
    …
    google {
      api = org.scribe.builder.api.GoogleApi
      key = 'oauth_google_key'
      secret = 'oauth_google_secret'
      successUri = '/oauth/google/success'
      failureUri = '/oauth/google/error'
      callback = "${baseURL}/oauth/google/callback"
      scope = 'https://www.googleapis.com/auth/userinfo.email'
    }
    …
  }
}

for Google OAuth 2.0

oauth {
  …
  providers {
    …
    google {
      api = org.scribe.builder.api.GoogleApi20
      key = 'oauth_google_key'
      secret = 'oauth_google_secret'
      successUri = '/oauth/google/success'
      failureUri = '/oauth/google/error'
      callback = "${baseURL}/oauth/google/callback"
      scope = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
    }
    …
  }
}

In your view you can use the taglib exposed from this plugin and from OAuth plugin to create links and to know if the user is authenticated with a given provider:

<oauth:connect provider="google" id="google-connect-link">Google</oauth:connect>

Logged with google? <s2o:ifLoggedInWith provider="google">yes</s2o:ifLoggedInWith> <s2o:ifNotLoggedInWith provider="google">no</s2o:ifNotLoggedInWith>