[英]Cognito wont switch unauthenticated user to authenticated user
I'm using a Cognito userpool and Cognito federated identities to pass an IAM role to authenticated and unauthenticated users. 我正在使用Cognito用户池和Cognito联合身份将IAM角色传递给经过身份验证和未经身份验证的用户。 When I try to switch a user from unauthenticated to authenticated, the developer console doesn't register that the change has happened;
当我尝试将用户从未经身份验证的用户切换为经过身份验证的用户时,开发人员控制台不会注册已发生更改; it is showing that I have 100% unauthenticated users.
显示我有100%未经身份验证的用户。
Right now I instantiate my AWS client as an unauthenticated user and then call a function to update the credentials when they are available so I can switch them to authenticated. 现在,我将我的AWS客户端实例化为未经身份验证的用户,然后调用一个函数以在凭据可用时更新凭据,以便可以将其切换为经过身份验证。 Eg:
例如:
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;
};
As best as I can tell, this is the correct way to do this. 据我所知,这是正确的方法。 See the documentation at the bottom of this page , and here , and here .
请参阅此页面底部 , 此处和此处的文档。
However, my console shows that I have no authenticated users, so updateCredentials
is not switching users to authenticated. 但是,我的控制台显示我没有经过身份验证的用户,因此
updateCredentials
不会将用户切换到经过身份验证的用户。 What can be done to fix this? 如何解决这个问题?
最后调用AWS.config.credentials.get(()....)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.