【问题标题】:Unable to get updated attributes and their values from cognito with aws-amplify无法使用 aws-amplify 从 cognito 获取更新的属性及其值
【发布时间】:2021-07-14 22:06:56
【问题描述】:

无法从 Cognito 获取当前属性及其值

这是我所做的完整流程

  1. 使用 aws-amplify 成功登录
  2. const cognitoUser = await Auth.currentAuthenticatedUser(); console.log("cognitoUser", cognitoUser);
  3. 获得了所有正确的 Cognito 用户属性信息(姓名、子、电子邮件、email_verified)
  4. 调用后端 API 来更新用户信息(添加了一个属性“profile”:1)
  5. 从 Cognito 用户池中检查,已成功添加并且“profile”:1 在那里
  6. 我又做了一次 const cognitoUser = await Auth.currentAuthenticatedUser(); console.log("cognitoUser", cognitoUser);
  7. 再次获得旧结果(姓名、子、电子邮件、email_verified)。 “个人资料”:1 不存在
  8. 使用 aws-amplify 成功退出
  9. 再次登录
  10. 这次从console.log得到的key是(name、sub、email、email_verified、profile)

【问题讨论】:

    标签: javascript reactjs amazon-web-services amazon-cognito aws-amplify


    【解决方案1】:

    经过大量搜索,我找到了答案。 有一种叫做绕过缓存的东西。这就是我们可以使用它的方式

    import { Auth } from 'aws-amplify';
    
    Auth.currentAuthenticatedUser({
        bypassCache: false  // Optional, By default is false. If set to true, this call will send a request to Cognito to get the latest user data
    }).then(user => console.log(user))
    .catch(err => console.log(err));
    

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 2022-12-10
      • 2022-01-21
      • 2019-05-08
      • 2020-05-29
      • 2020-06-26
      • 2019-09-08
      • 2019-12-16
      • 2021-03-09
      相关资源
      最近更新 更多