简体   繁体   English

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

[英]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.

相关问题 AWS - JavaScript - 使用经过身份验证的 Cognito 用户对 DynamoDB 进行 CRUD 操作 - AWS - JavaScript - CRUD operations on DynamoDB with authenticated Cognito user 如何使用 React 显示使用 Cognito 进行身份验证的用户组? - How to display group of a user authenticated using Cognito using React? 用户通过cognito身份验证后,如何通过用户凭据访问s3存储桶? - How do i pass the user credential to access s3 bucket once user is authenticated by cognito? 重定向未经身份验证的用户 nuxt js - Redirect unauthenticated user nuxt js 在mounted() 中阻止应用程序,直到用户使用Amazon cognito 和Vue.js 进行身份验证 - Block the app in mounted() until the user is authenticated using Amazon cognito and Vue.js AWS IoT Core 连接被带有附加策略的经过身份验证的 Cognito 用户拒绝 [MQTT over WSS] - AWS IoT Core connection refused with authenticated Cognito user w/ attached policy [MQTT over WSS] 如何只允许经过身份验证的用户(使用Cognito)访问他们自己的S3存储桶/密钥? - How do I only allow authenticated user (using cognito) access to their own S3 bucket/key specifically? 使用AWS Cognito,我可以在给定禁用的未经身份验证的IdentityId的情况下解析经过身份验证的IdentityId吗? - Using AWS Cognito can I resolve the authenticated IdentityId given a disabled unauthenticated IdentityId? 如何为属于多个用户池组的 AWS Cognito 用户切换 IAM 角色? - How to switch IAM roles for AWS Cognito User belonging to multiple User Pool groups? 检查用户是否已同步认证 - Check if user is authenticated synchronously
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM