我正在使用Angular 4,并在收到我的IdP的SAML响应后尝试对给定用户进行身份验证,但AWS返回“找不到400个身份池ID”错误。
我确认这是aws控制台显示的正确ID,并且所有内容都位于同一区域(us-west-2)。
以下是相关代码:
//Initialize
let cognitoIdentity = new AWS.CognitoIdentity({apiVersion: 'latest', region: environment.cognitoRegion});
cognitoIdentity.config.credentials = new AWSCognito.CognitoIdentityCredentials({IdentityPoolId: environment.identityPoolId});
cognitoIdentity.config.update({accessKeyId: 'anything', secretAccessKey: 'anything'})
//Setup params for authentication
var params = {
IdentityId: environment.identityPoolId,
Logins: {
[environment.SAMLProviderARN]: '<super long base64 saml response>'
}
};
//Get credentials for user
cognitoIdentity.getCredentialsForIdentity(params, function(err, data) {
//log error or sucessful response
if (err){
console.log(err, err.stack); // an error occurred
}
else {
console.log(data); // successful response
}
});
identityPoolId:'us-west-2:52xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxd0'
cognitoRegion:'us-west-2'
SAMLProviderARN:arn:aws:iam ::(accountID):saml-provider / secpov-shibboleth
但我仍然得到400“ResourceNotFoundException:Identity'us-west-2:52 ... d0'找不到。”
答案 0 :(得分:0)
您看到此400错误的原因是您将“IdentityPoolId”分配给参数数组的“IdentityId”属性。
在您的参数数组中,将属性的名称更改为IdentityPoolId。这将解决这400错误。