3
votes

I've setup AWS Cognito with a Google identity provider as described in https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html.

Users can login but I only seem to get back the users email, email_verified and a username like Google_xxxxxxxxxxxxxxx in my auth callback and cognito login/signup Lambda hooks.

Is there a way to also get the users first & last name?

I've set profile email openid as the authorize scope.

Also tried using googleapis npm package to call oauth2.userinfo.get as in How to use the node google client api to get user profile with already fetched token? but the access token I get back is from Cogntio not google which is why I assume this didn't work for me.

1

1 Answers

6
votes

I've not tried this but I know the theory.

In Cognito, go to Federation -> Attribute Mapping -> Select Google from the tabs -> Check given_name and map it to Given Name, Check family_name and map it to Family Name.

EDIT: Also, you will need to parse the Identity Token from Cognito rather than the Access Token I think.