1

I am integrating google signin in my app.I need to store email,name,agerange,location.So while doing signin, i have set the scope to profile,email and profile.auth.agerange.read.

gapi.signin2.render('g-signin2', {
    'scope': 'email profile https://www.googleapis.com/auth/userinfo.profile openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/profile.agerange.read',
    'width': 240,
    'height': 50,
    'longtitle': true,
    'theme': 'dark',
    'onsuccess': onSuccess,
    'onfailure': onFailure
  });

But still when i am verifying the generated id_token using GoogleIdTokenVerifier i can't see age or location field in the payload.

Can anyone suggest how to get those details.

Manish
  • 1,274
  • 3
  • 22
  • 59
  • Hi Manish, have you ever found solution for this. Do we need to call API separately for getting age? – deen Mar 29 '22 at 06:49

2 Answers2

2

Most likely location and age group wouldn't be provided with a basic payload. And you would be needed to call an additional API(s):

Also, take a look into get-user-info-via-google-api topic.

0

https://developers.google.com/identity/sign-in/web/people https://developers.google.com/people/api/rest/v1/people#agerangetype

You can also get dob from api and calculate the age of the user. location string can also get from the rest api response from google.

Maxx Selva K
  • 454
  • 4
  • 9