![](/img/trans.png)
[英]AWS / iOS / Cognito: unauthenticated access is not supported for this identity pool
[英]iOS - Login in with Facebook but still getting: “Unauthenticated access is not supported for this identity pool”
我正在使用AWS開發iOS應用程序。 我正在嘗試從DynamoDB表中獲取項目,但是卻遇到了錯誤(它有時不起作用!!!就像4個小時的工作然后掉了下來)
{
__type=com.amazon.coral.service#AccessDeniedException,
Message=User:arn:aws:sts::306752704279:
assumed-role/Cognito_equo_MOBILEHUB_1429140868Unauth_Role/CognitoIdentityCredentials
is not authorized to perform: dynamodb:Query on resource:
arn:aws:dynamodb:us-east-1:306752704279:table/equo-mobilehub-1429140868-TripActive/index/searchByOwner
}
我不希望我的應用程序具有未經身份驗證的用戶,但是我在調用DynamoDB查詢之前先登錄。 誰能幫我? 這是我用於查詢的代碼:(我正在使用登錄的de Generated Code)
-(void) getUserHorsesWithMax: (int)pMax page:(int) pPage {
dispatch_async(dispatch_get_main_queue(), ^{
loading = true;
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"us-east-1:a1372699-48b0-499a-bf17-84811860a8bb"];
[[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
}
else {
// the task result will contain the identity id
NSString *cognitoId = task.result;
AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
AWSDynamoDBQueryExpression *queryExpression = [AWSDynamoDBQueryExpression new];
queryExpression.indexName = @"searchByOwner";
queryExpression.expressionAttributeValues = @{@":owID":cognitoId};
queryExpression.keyConditionExpression = @"ownerId=:owID";
[[dynamoDBObjectMapper query:[TripActive class]
expression:queryExpression]
continueWithBlock:^id(AWSTask *task) {
loading = false;
if (task.error) {
NSLog(@"The request failed. Error: [%@]", task.error);
}
if (task.exception) {
NSLog(@"The request failed. Exception: [%@]", task.exception);
}
if (task.result) {
dispatch_async(dispatch_get_main_queue(), ^{
AWSDynamoDBPaginatedOutput *paginatedOutput = task.result;
horses = [NSMutableArray new];
for (Horse *horse in paginatedOutput.items) {
//Do something with horse.
if (self.segmentedTrips.selectedSegmentIndex == FUTURE_TRIPS) {
} else if (self.segmentedTrips.selectedSegmentIndex == ACTIVE_TRIPS) {
[horses addObject:horse];
} else if (self.segmentedTrips.selectedSegmentIndex == PAST_TRIPS) {
}
}
[UIView animateWithDuration:0.2 animations:^(void) {
self.tripsTableView.alpha = 1.0f;
} completion:^(BOOL finished) {
self.tripsTableView.hidden = false;
}];
[self.tripsTableView reloadData];
});
}
return nil;
}];
}
return nil;
}];
});
}
請幫我!
您得到的異常意味着調用Cognito獲取憑據時登錄映射為空。 這是在應用打開/關閉期間發生的嗎? 還是要讓該應用保持打開狀態4個小時?
確保登錄映射始終包含提供者和來自提供者的令牌。
此外,請確保您使用的是最新版本的iOS SDK。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.