Amazon web services 检索用户';aws放大与谷歌联合登录后的姓名和电子邮件

Amazon web services 检索用户';aws放大与谷歌联合登录后的姓名和电子邮件,amazon-web-services,oauth,google-oauth,amazon-cognito,aws-amplify,Amazon Web Services,Oauth,Google Oauth,Amazon Cognito,Aws Amplify,我正在使用aws amplify将我的用户登录到我的网站。我正在使用 Auth.federatedSignIn({provider: 'Google'}); 让他们登录。当他们点击他们的电子邮件时,他们被添加到一个用户池中,在那里他们的用户名看起来像 Google_12345678901234567890 当你点击用户池中的谷歌用户名时,他们的电子邮件和名字就会出现在个人资料中。如何通过我的密码访问用户名和电子邮件 我试过了 Auth.currentAuthenticatedUser()

我正在使用aws amplify将我的用户登录到我的网站。我正在使用

Auth.federatedSignIn({provider: 'Google'});
让他们登录。当他们点击他们的电子邮件时,他们被添加到一个用户池中,在那里他们的用户名看起来像

Google_12345678901234567890
当你点击用户池中的谷歌用户名时,他们的电子邮件和名字就会出现在个人资料中。如何通过我的密码访问用户名和电子邮件

我试过了

Auth.currentAuthenticatedUser()

两者都不包含该信息,以及
Auth.currentUserInfo()
返回空的,并且

Auth.userAttributes()

这似乎不起作用。任何想法都将不胜感激。谢谢大家!

我回答了我自己的问题。在与

Auth.federatedSignIn({provider: 'Google'});
我运行了以下代码:

Auth.currentSession()
    .then(data => {
        let idToken = data.getIdToken();
        console.dir(idToken);
        let email = idToken.payload.email;
        console.log(email);
    })
    .catch(err => console.log(err));
所有信息都位于id令牌中,可以通过

console.dir(idToken);

正如Eyal Cohen所提到的,您需要通过转到属性映射来映射属性,然后按如下方式检索属性:

const func = async() => {
      user = await Auth.currentAuthenticatedUser();
      user = user.attributes; //all attributes exist in the attributes field   
}
        
func();

这很好,但不返回用户配置文件图片/名称,只返回电子邮件。。你知道怎么做吗?真的!在您的用户池中的“federation”下,转到属性映射,并在其中设置您想要的oauth数据与Congito响应名称之间的映射。如果不成功的话我会的,好吧!感谢您的快速回复,现在我已经添加了图片作为谷歌属性和图片从下拉菜单从用户池属性,但我在哪里检索它?因为如果我记录我的Auth.currentSession()它不在那里?
const func = async() => {
      user = await Auth.currentAuthenticatedUser();
      user = user.attributes; //all attributes exist in the attributes field   
}
        
func();