2017-05-26 82 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

相關問題