【问题标题】:Cognito wont switch unauthenticated user to authenticated userCognito 不会将未经身份验证的用户切换到经过身份验证的用户
【发布时间】:2018-01-07 09:26:50
【问题描述】:

我正在使用 Cognito 用户池和 Cognito 联合身份将 IAM 角色传递给经过身份验证和未经身份验证的用户。当我尝试将用户从未经身份验证切换到经过身份验证时,开发人员控制台不会记录更改已发生;这表明我有 100% 未经身份验证的用户。

现在我将我的 AWS 客户端实例化为未经身份验证的用户,然后调用一个函数来更新可用的凭证,以便我可以将它们切换为经过身份验证的用户。例如:

AWS.config.region = 'us-west-2';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
  IdentityPoolId: identityPoolId,
  region: 'us-west-2',
  Logins: {}
});

const updateCredentials = () => {
  const auth = store.getState().auth; //this gets the authentication credentials from a global store.
  AWS.config.credentials.Logins = {
    'cognito-idp.us-west-2.amazonaws.com/us-west-2_XXXXXXXXX': auth.idToken
  };
  AWS.config.credentials.expired = true;
};

据我所知,这是正确的方法。请参阅文档at the bottom of this pageherehere

但是,我的控制台显示我没有经过身份验证的用户,因此updateCredentials 没有将用户切换到经过身份验证的用户。有什么办法可以解决这个问题?

【问题讨论】:

    标签: javascript amazon-web-services amazon-cognito


    【解决方案1】:

    结束通话AWS.config.credentials.get(()....)

    【讨论】:

    • 这没有提供问题的答案。要批评或要求作者澄清,请在他们的帖子下方留下评论。 - From Review
    • 这是一个解决方案,问题是关于没有创建 cognito 用户...并使用 .get... 创建它并显示在控制台中
    • UXDart 是正确的,Logister 所做的是填充一些静态地图。由于某种原因,AWS Javascript SDK 需要调用 get 或 refresh 以实际检索凭证。否则,用户将显示为未经身份验证。
    猜你喜欢
    • 2020-11-15
    • 2016-01-17
    • 2019-09-25
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 2017-09-11
    • 2019-01-29
    • 1970-01-01
    相关资源
    最近更新 更多