我已按照https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social-idp.html中的说明使用Google身份提供商设置了AWS Cognito。
用户可以登录,但我似乎只在身份验证回调和认知登录/注册Lambda挂钩中找回了用户email
,email_verified
和username
,例如Google_xxxxxxxxxxxxxxx
。
是否也可以获取用户的名字和姓氏?
我已将profile email openid
设置为授权范围。
[也尝试使用googleapis
npm程序包像oauth2.userinfo.get
一样调用How to use the node google client api to get user profile with already fetched token?,但我获得的访问令牌是来自Cogntio而不是google,这就是为什么我认为这对我不起作用的原因。
我没有尝试过,但是我知道理论。
在Cognito中,转到“联合身份验证->属性映射->从选项卡中选择Google->检查给定名称并将其映射到给定名称,检查家庭名称并将其映射到姓氏。”>
编辑:此外,您将需要从Cognito解析身份令牌,而不是我认为的访问令牌。