AWS Cognito无效身份池配置
问题描述:
我正在使用AWS Javascript API并尝试获取分配的认知ID:
I am using the AWS Javascript API and trying to get the assigned cognito id:
AWS.config.credentials.get(function(err) {
if (!err) {
console.log("Cognito Identity Id: " + AWS.config.credentials.identityId);
}
});
为什么以下消息会导致400错误?
Why does this result in a 400 error with the message below?
{"__type":"InvalidIdentityPoolConfigurationException","message":"Invalid identity pool configuration. Check assigned IAM roles for this pool."}
我为经过身份验证和未经过身份验证的用户配置了IAM角色。
I have IAM roles configured for authenticated and non-authenticated users.
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Effect": "Allow",
"Resource": [
"*"
]
}]
}
答
此错误的最常见原因是您的角色未设置为信任您的身份池。您应确认信任关系中列出的身份池ID与您正在使用的身份池匹配。
The most common reason for this error is your roles aren't set up to trust your identity pool. You should confirm that the identity pool id listed in your trust relationships matches the identity pool you are using.
有关Amazon Cognito中信任关系的更多信息,请参见我们的开发人员指南。
More info on trust relationships in Amazon Cognito can be found in our developer guide.