In my last blog Integration with Google using Grails Oauth Plugin, we have seen the steps to connect/authenticate with Google using grails oauth plugin. The code in the blog works fine but uses OAuth 1.0.

Google shows different screen for OAuth 1.0 and OAuth 2.0 for asking permissions.

Google screen for OAuth 1.0
Google Authentication Screen for OAuth 1.0

And Google screen for OAuth 2.0

Google Authentication Screen for OAuth 2.0

I have seen many questions on Stack Overflow that asking for OAuth 2.0 screen for Google authentication.

I searched a lot for this and the result is AWESOME 😎 . A BIG THANKS to Michael Yin for providing this Gist that helps me to resolve the issue.

Step 1 : Install plugin and configure project for Google+

Perform all the steps mentioned in my previous blog.

Step 1 : Add file in your scr/java

Create a java file in your scr/java and put following code in that:

NOTE:- Package of this file must not be org.scribe.builder.api. If you place this java file in org.scribe.builder.api package then you got ERROR 🙁 Error creating bean with name ‘oauthService’: Invocation of init method failed; nested exception is java.lang.NoSuchFieldError

Step 2 : Use Google2Api in Config.groovy

Replace GoogleApi with Google2Api in your Config.groovy:

And that’s all.

You can get working code in the repository Grails Oauth Plugin Demo.

I have deployed Grails Oauth Plugin Demo project in Heroku.

See this project in action (DEMO).

Hope this helps. 🙂