gpt4 book ai didi

amazon-web-services - 什么是 Cognito IdentityId?

转载 作者:行者123 更新时间:2023-12-04 08:06:49 29 4
gpt4 key购买 nike

我正在尝试为我刚刚创建的用户获取 AWS 凭证。

谁能告诉我identityId应该是?我尝试将区域与用户 sub 连接,但它没有:

var params = {
UserPoolId: process.env.USER_POOL_ID,
Username: 'xxx@gmail.com',
TemporaryPassword: 'Passw0rd!'
};

var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();
cognitoidentityserviceprovider.adminCreateUser(params, function(err, data) {
if (err) {
callback(null, failure(err));
}else
var identityId = "us-east-1:" + data.User.Username //user sub

var cognitoidentity = new AWS.CognitoIdentity();
cognitoidentity.getCredentialsForIdentity(
{"IdentityId": identityId},
(err, credResult) => {
if(err){
callback(null, failure(err));
}
callback(null, success(credResult));
})
});

我只是得到:
{
"message":"Identity 'us-east-1:8ce7ee63-d9ae-4f12-9xxxxxx' not found.",
"code":"ResourceNotFoundException","t": "..."
}

最佳答案

您似乎将 Cognito 用户池与 Cognito 联合身份混合在一起。
Cognito 用户池是您管理用户的地方,而联合身份是您授予外部用户 AWS 凭证访问权限的地方。

也就是说,您必须确保将身份池(来自联合身份)配置为授予用户池中的用户访问权限。这可能会对您有所帮助 https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-integrating-user-pools-with-identity-pools.html

设置完成后,您可以调用 CognitoIdentity.getId只有在您获得凭据之后才会提供您的 IdentityId。

总结一下:IdentityId 是您的用户在 Cognito Federated Identities 的身份池中的 ID。

关于amazon-web-services - 什么是 Cognito IdentityId?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48463595/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com