Cognito不会将未经身份验证的用户切换为经过身份验证的用户

时间:2017-07-31 17:40:08

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

我正在使用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未将用户切换为经过身份验证。可以做些什么来解决这个问题?

1 个答案:

答案 0 :(得分:1)

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

相关问题