2014-12-22 52 views
0

我對亞馬遜Cognito我們開發者認證的身份集我的iOS應用Amazon Web服務:錯誤 - 請求中包含的安全令牌是無效的

我按照文檔中的教程: Using Developer Authenticated Identities

我的後端能夠生成標記並獲得身份標識而沒有問題。 我可以按照指示在iOS應用程序中初始化cognito。 但我須在dynamoDb請求,我得到的錯誤

The security token included in the request is invalid 

Cognito初始化代碼:

MyIdentityProvider *identityProvider = [MyIdentityProvider new]; 
[identityProvider setIdentityPoolId:COGNITO_POOL_ID]; 

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] 
                 initWithRegionType:AWSRegionUSEast1 
                 identityProvider:identityProvider 
                 unauthRoleArn:nil 
                 authRoleArn:COGNITO_ROLE_AUTH]; 




AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 
                     credentialsProvider:credentialsProvider]; 

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; 





[[credentialsProvider getIdentityId] continueWithSuccessBlock:^id(BFTask *task){ 

//In here I can see that everything is ok. 
//I have a token and cognitoId 
//But despite this, when I make requests I get "The security token included in the request is invalid" 

return nil; 
}]; 

有誰知道我可能是做錯了什麼?

+0

您應該通過調用'[AWSLogger defaultLogger] .logLevel = AWSLogLevelVerbose;'來啓用詳細日誌記錄。這可能是調試問題的一個很好的第一步。 –

回答

0

getIdentityId只保證您購買的identityId,你可能會想驗證可以成功調用refresh的憑據提供,因爲這將確保您能順利拿到證書。在生產中明確地調用refresh不應該是必需的,但可以在測試中有價值。

有一件事可能會讓你失望,那就是你沒有包含一個非真實的角色。確保您的身份提供商沒有遇到this question中指出的問題,這些問題會阻止它提取您的身份驗證角色。

+0

我檢查了刷新並創建了一個未經驗證的角色來使用。我現在正在「未授權執行sts:AssumeRoleWithWebIdentity」錯誤。我已檢查角色信任和權限,一切都按順序...任何想法? – Zigglzworth

+0

更新:這個問題解決了這個問題。 – Zigglzworth

相關問題