我正在使用 AWS Cognito 进行用户身份验证,我正在尝试测试未经身份验证的用户,但我从 Cognito 得到的只是一个空身份。下面的代码是关于 viewDidLoad 方法的:
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;
}];
所以从上面的 NSLog 我得到:
cognitoId: (null)
以下是授权和未授权用户的认知认证策略:
{
"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}/*"]
}]
}
任何想法可能是什么,或者我做错了什么?