gpt4 book ai didi

ios - AWS Cognito 身份空

转载 作者:可可西里 更新时间:2023-11-01 05:35:06 26 4
gpt4 key购买 nike

我正在使用 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}/*"]
}]
}

任何想法可能是什么,或者我做错了什么?

最佳答案

请运行这段代码并告诉错误。

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

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

return nil;
}];

关于ios - AWS Cognito 身份空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25245236/

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