简体   繁体   English

iOS-使用Facebook登录,但仍然得到:“此身份池不支持未经身份验证的访问”

[英]iOS - Login in with Facebook but still getting: “Unauthenticated access is not supported for this identity pool”

I am working for an iOS App using AWS. 我正在使用AWS开发iOS应用程序。 I am trying to get items from my DynamoDB table but I am getting the error (From time to time it works!!! Like 4 hours working then goes down) 我正在尝试从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
 }

I don't want my app to have Unauthenticated users, but I AM LOGIN IN before calling the DynamoDB query. 我不希望我的应用程序具有未经身份验证的用户,但是我在调​​用DynamoDB查询之前先登录。 Can Anyone help me? 谁能帮我? Here's my code for the query: (I am using de Generated Code for the LogIn) 这是我用于查询的代码:(我正在使用登录的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;
    }];

    });


}

PLEASE HELP ME! 请帮我!

The exception you are getting means that the logins map is empty when calling Cognito to get credentials. 您得到的异常意味着调用Cognito获取凭据时登录映射为空。 Is this happening during app open/close? 这是在应用打开/关闭期间发生的吗? Or are you keeping the app open for 4 hours? 还是要让该应用保持打开状态4个小时?

Make sure that the logins map always contains the provider and token from the provider. 确保登录映射始终包含提供者和来自提供者的令牌。

Additionally, please make sure you are using the most recent version of the iOS SDK. 此外,请确保您使用的是最新版本的iOS SDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS / iOS / Cognito:此身份池不支持未经身份验证的访问 - AWS / iOS / Cognito: unauthenticated access is not supported for this identity pool 该身份池和用户池不支持未经身份验证的访问 - Unauthenticated access is not supported for this identity pool with user pool AWS Cognito:“此身份池不支持未经身份验证的访问权限。” - AWS Cognito: “Unauthenticated access is not supported for this identity pool.” 使用DynamoDB时,此标识池不支持未经身份验证的访问 - Unauthenticated access is not supported for this identity pool, while using DynamoDB 获取xmpp_login访问令牌在Facebook iOS SDK中不起作用 - Getting xmpp_login Access Token Not Working in Facebook iOS SDK 在Facebook SIgnin按钮上,我在iOS中获得标题为“使用Facebook登录”吗? - On facebook SIgnin button im getting the title as Login with Facebook in ios? 如何实现仅针对未经身份验证的用户显示的iOS登录屏幕 - How to implement an iOS login screen that only appears for unauthenticated users 将DynamoDB与Cognito一起使用:令牌不是来自此身份池的受支持提供商 - Using DynamoDB With Cognito: Token is not from a supported provider of this identity pool 无需用户登录即可在 iOS 上获取 facebook 墙贴 - Getting facebook wall posts without user login on iOS iOS:通过自动登录获取Facebook访问令牌 - iOS: Get Facebook Access Token with Auto-Login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM