Retrieving date of birth and marital status with Google OAuth API

14,979

Set scope to

https://www.googleapis.com/auth/plus.login

and request url is

https://www.googleapis.com/plus/v1/people/me

NOTE:- Relationship Status and Birthday only available to you if user set them public.

Have a look to this google api explorer.

I have tried this using grails oauth plugin and make my birthday and relationship status public it gives me

[birthday:1988-04-02, ..., relationshipStatus:single, ...]

EDIT.................................................................................

Q. New problem with email, I can't get it after changes

You can set multiple scopes like:

https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login

and make two requests one for birthday and relationship status

https://www.googleapis.com/plus/v1/people/me

and another for email

https://www.googleapis.com/oauth2/v2/userinfo
Share:
14,979
emilan
Author by

emilan

Updated on July 20, 2022

Comments

  • emilan
    emilan almost 2 years

    I'm trying to retrieve date of birth and marital status via Google OAuth api. I get below mentioned info by setting the scopes as https://www.googleapis.com/auth/userinfo.profile & https://www.googleapis.com/auth/userinfo.email . Request URL is https://www.googleapis.com/oauth2/v2/userinfo

    {
     "id": "my_id",
     "email": "[email protected]",
     "verified_email": true,
     "name": "full_name",
     "given_name": "first_name",
     "family_name": "last_name",
     "link": "https://plus.google.com/xxxxxxx",
     "picture": "https://xxxxxxxxx/photo.jpg",
     "gender": "male",
     "locale": "en"
    }
    

    I have birthday and marital status set in my profile, but I'm unable to get this info. What could the problem be?

  • emilan
    emilan over 10 years
    Excellent, thanks for help, but I'm just wonder, when I hide year of birth in my profile I receive 0000 instead of it. It's bit a strange, cause actually I don't need month and day of birth without year.
  • MKB
    MKB over 10 years
    Have a look to this answer stackoverflow.com/questions/15646474/…
  • emilan
    emilan over 10 years
    Yes, but it's a little stupid of google. Anyway thanks for help.
  • emilan
    emilan over 10 years
    New problem with email, I can't get it after changes.