gpt4 book ai didi

iOS - 使用 Facebook 登录但仍然收到 : “Unauthenticated access is not supported for this identity pool”

转载 作者:行者123 更新时间:2023-11-29 00:54:47 26 4
gpt4 key购买 nike

我正在使用 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 查询之前登录。谁能帮我?这是我的查询代码:(我正在为登录使用生成的代码)

-(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 小时?

确保登录映射始终包含提供商和来自提供商的 token 。

此外,请确保您使用的是最新版本的 iOS SDK。

关于iOS - 使用 Facebook 登录但仍然收到 : “Unauthenticated access is not supported for this identity pool” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37716050/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com