2017-05-26 133 views
0

我正在使用Angular 4,并且在我从我的IdP收到SAML响应后尝试对给定用户进行身份验证,但AWS返回'400身份池ID未找到'错误。AWS Cognito,Angular,不识别身份池ID

我确认它是aws控制台显示的正确标识,并且所有内容都位于同一区域(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:身份 '美西2:52 ...... D0'。找不到”

+0

你能分享你的'环境'变量吗?我可以检查Cognito数据存储以查看池的外观。 –

+0

已更新w/info – canada11

回答

0

您看到这个400错误的原因是因为您正在将“IdentityPoolId”分配到参数数组的“IdentityId”属性中。

在参数数组中将属性的名称更改为IdentityPoolId。这将解决这个400错误。

+0

因此,当我尝试这样做时有意义,它返回IdentityPoolId是一个无法识别的参数,并且IdentityId是必需的: '错误:有2个验证错误: * MissingRequiredParameter:缺少必需的键'IdentityId 'in params * UnexpectedParameter:在参数中发现意外的'IdentityPoolId' 我也试图使用IdentityId,它说'Value'us-west-2_IjGKTnExQ''identityId'未能满足约束:成员必须满足常规表达模式:[\ w - ] +:[0-9a-f - ] +' 所以,它确实需要id为池ID,但不会识别我的 – canada11

相关问题