0
我正在使用AWS爲iOS應用程序工作。我想從我的DynamoDB表中獲取的項目,但我得到的錯誤(從時間到它的工作時間!樣4小時的工作,然後下山)iOS - 用Facebook登錄,但仍然得到:「此身份池不支持未經身份驗證的訪問」
{
__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生成的代碼LogIn)
-(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;
}];
});
}
請幫助我!
你有沒有在tsk.result .....數據或不。 –
包含Cognito ID的task.result,實際上獲得了真正的Cognito ID @AbhishekMishra –