2015-11-06 53 views
0

我有一個使用Google SignIn的iOS應用程序,我想使用Google令牌ID對AWS進行身份驗證。AWS Google登錄 - 查詢Dynamo數據庫訪問被拒絕錯誤

我在Cognito中創建了IAM和Identity Pool中的角色。當我嘗試查詢Dynamo中的表時。我越來越

'Not authorized to perform sts:AssumeRoleWithWebIdentity' 

我有我的谷歌客戶端ID可信的政策,

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
    { 
     "Sid": "", 
     "Effect": "Allow", 
     "Principal": { 
     "Federated": "accounts.google.com" 
     }, 
     "Action": "sts:AssumeRoleWithWebIdentity", 
     "Condition": { 
     "StringEquals": { 
     "accounts.google.com:aud": #mygoogleclientid# 
    } 
    } 
} 
]} 

錯誤

Error: Error Domain=com.amazonaws.AWSSTSErrorDomain Code=0 "(null)" UserInfo= 
    { 
    Type=Sender, 
    Message=Not authorized to perform sts:AssumeRoleWithWebIdentity, 
    Code=AccessDenied, __text=(
    "\n ", 
    "\n ", 
    "\n ", 
    "\n " 
)} 

我想知道爲什麼我得到這個錯誤和解決方案來解決這個。

回答

0

我建議您嘗試增強型Authflow,這樣Cognito會爲您創建sts:AssumeRoleWithWebIdentity調用。

參考這裏的驗證流程文檔: http://docs.aws.amazon.com/cognito/devguide/identity/concepts/authentication-flow/

這裏是Cognito的基本認證流程: GETID - > GetOpenIdToken(Cognito的Open ID令牌) - > AssumeRoleWithWebIdentity(通過Cognito的Open ID令牌)。

如果您在AWS控制檯中創建身份池,則會設置默認策略以使用增強流或基本流。您只需爲DynamoDB訪問權限和其他要與其集成的服務添加策略。