我不明白为什么我的应用程序崩溃时使用此代码。但没有它我无法使用DynamoDB - 我的调试中有这个错误
错误:无法完成操作。 (com.amazonaws.AWSCognitoIdentityErrorDomain错误0。)
错误Domain = com.amazonaws.AWSServiceErrorDomain Code = 6“(null)”UserInfo = {__ type = com.amazon.coral.service #AccessDeniedException,Message = User:arn:aws:sts ::: assume-role / production_auth_MOBILEHUB_ / CognitoIdentityCredentials无权执行:dynamodb:资源上的GetItem:arn:aws:dynamodb:eu-central-1 :: table / production-mobilehub}
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: .EUCentral1, identityPoolId: "MY_IDENTITY_POOL_ID")
let configuration = AWSServiceConfiguration(region: .EUCentral1, credentialsProvider: credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
credentialsProvider.getIdentityId().continueWith(block: { (task) -> AnyObject? in
if (task.error != nil) {
print("Error: " + task.error!.localizedDescription)
}
else {
// the task result will contain the identity id
let cognitoId = task.result!
print("Cognito id: \(cognitoId)")
}
return task;
})
credentialsProvider.setValue(AWSCognitoUserPoolsSignInProviderKey, forKey: Token.sharedInstance.tokenID)