简体   繁体   中英

AWS Cognito Google Identity Provider Get Profile First & Last Name

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM