Ionic 2 Google Sign-in - retrieve gender and birthday

I am trying to build an Ionic 2 App with google sign in and I need to retrieve the persons gender and birthday.

This is my code so far:

doGoogleLogin() {
    GooglePlus.login(
      {
        'scopes': 'profile',
        'webClientId': 'myClientId'
      }
    )
    .then(userData => {
      let token = userData.idToken;
      console.log(JSON.stringify(userData);
    })
    .catch(err => console.error(err));
}

The userData only contains an idToken, email and name of the user.
Ionics Google Plus Plugin does not provide a function for calling any other API endpoint. I already tried to get an oauth access token from https://accounts.google.com/o/oauth2/v2/auth and use the Google People API with https calls but I could not make it work.

Any help will be appreciated!

These sources may also be helpful: Google People API, OAuth 2.0 for Mobile Apps

Which API actually provides the gender and birthday of the logged in person?

The People API with scope “profile” provides gender and birthday of the user. I tested it in Googles OAuth Playground.

EDIT: I currently can’t reproduce getting the birthday from this API. Seems like Í need to use the Google+ API and set the birthday to public in my account. I also can’t find a scope for reading the users birthday. There are just too many APIs and too many options, this is so annoying…

1 Like

Did anyone get this working? If so how…