In my previous blogs we have seen how to integration with Google using grails oauth plugin.
- Integration with Google using Grails Oauth Plugin
- Integration with Google Using OAuth 2.0 via Grails OAuth Plugin
In these blogs I have set https://www.googleapis.com/auth/userinfo.profile in the scope and https://www.googleapis.com/oauth2/v1/userinfo in the request URL. Using these settings you got the following response from Google
1 2 3 4 5 6 7 8 9 10 11 12 |
[code lang="html"] { "id": "105644818942274155217", "name": "Manish Bharti", "given_name": "Manish", "family_name": "Bharti", "link": "https://plus.google.com/105644818942274155217", "picture": "https://lh3.googleusercontent.com/-7fB8TQ22IRQ/AAAAAAAAAAI/AAAAAAAAACA/SgSzrch18TU/photo.jpg", "gender": "male", "locale": "en" } [/code] |
As you can see response does not includes relationship status and birth day. To get relationship status and birth day from Google you need to change scope (in config file) to
1 2 3 |
[code] https://www.googleapis.com/auth/plus.login [/code] |
and request URL (in OauthCallBack controller) to
1 2 3 |
[code] https://www.googleapis.com/plus/v1/people/me [/code] |
Now you got the following response from Google
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[code lang="html"] { "kind": "plus#person", "birthday": "1988-04-02", "gender": "male", "objectType": "person", "id": "105644818942274155217", "displayName": "Manish Bharti", "name": { "familyName": "Bharti", "givenName": "Manish" }, "relationshipStatus": "single", "url": "https://plus.google.com/105644818942274155217", "image": { "url": "https://lh3.googleusercontent.com/-7fB8TQ22IRQ/AAAAAAAAAAI/AAAAAAAAACA/SgSzrch18TU/photo.jpg?sz=50", "isDefault": false }, ... } [/code] |
which includes relationship status and birth day.
NOTE:- Relationship Status and Birthday only available to you if user set them public.
Can you please tell me how to get email id while implementing google authentication with Oauth plugin.
I have gone through your code and internet but I am not able to get email id.
Thank you in advance.
Hi Jennifer,
You can get the email address by adding https://www.googleapis.com/auth/userinfo.email in your scope (You can add multiple scopes, space separated).
Hi Jennifer,
You can get the email address by adding “https://www.googleapis.com/auth/userinfo.email” in your scope (You can add multiple scopes, space separated).