AWS Cognito Identity Null

I am using AWS Cognito to authenticate users, I am trying to test unverified users, but all I get from Cognito is null identity. The code below is in the viewDidLoad method:

AWSCognitoCredentialsProvider *credentialsProvider = [AWSCognitoCredentialsProvider
                       credentialsWithRegionType:AWSRegionUSEast1
                       accountId:@"XXXXXXXXXXXX"
                       identityPoolId:@"us-east-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
                       unauthRoleArn:@"arn:aws:iam::XXXXXXXXXXXX:role/Cognito_XXXXXXXXXUnauth_DefaultRole"
                       authRoleArn:@"arn:aws:iam::XXXXXXXXXXXX:role/Cognito_XXXXXXXXXAuth_DefaultRole"];

AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1
                                                                      credentialsProvider:credentialsProvider];

[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;

[[credentialsProvider getIdentityId] continueWithSuccessBlock:^id(BFTask *task){
    NSString* cognitoId = credentialsProvider.identityId;
    NSLog(@"cognitoId: %@", cognitoId);
    //[self launchCount];
    return nil;
}];

      

So, from the NSLog above, I get:

cognitoId: (null)

      

Below is the cognito authentication policy for authenticated and unauthorized users:

{
  "Version": "2012-10-17",
  "Statement":[{
  "Effect":"Allow",
  "Action":"cognito-sync:*",
  "Resource":["arn:aws:cognito-sync:us-east-1:XXXXXXXXXXXX:identitypool/${cognito- identity.amazonaws.com:aud}/identity/${cognito-identity.amazonaws.com:sub}/*"]
  }]
}

      

Any ideas what this might be or what I am doing wrong?

+3


source to share


1 answer


Run this code and report a bug.



[[credentialsProvider getIdentityId] continueWithBlock:^id(BFTask *task){

if (task.error == nil)
{
   NSString* cognitoId = credentialsProvider.identityId;
   NSLog(@"cognitoId: %@", cognitoId);               
}
else
{
    NSLog(@"Error : %@", task.error);
}

return nil;
}];

      

+5


source







All Articles