gpt4 book ai didi

ios - Cognito 身份验证有效但显示错误?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:38:17 25 4
gpt4 key购买 nike

基本上,我使用经过开发人员身份验证的身份来验证我的用户。即使显示此错误:

AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:87 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"InvalidParameterException","message":"Please provide a valid public provider"}] 2015-10-20 17:50:19.251 BusyTime[56549:7365231] AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:435 | __73-[AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:]_block_invoke | GetCredentialsForIdentity failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=7 "The operation couldn’t be completed. (com.amazonaws.AWSCognitoIdentityErrorDomain error 7.)" UserInfo=0x7f9d9342dde0 {__type=InvalidParameterException, message=Please provide a valid public provider}]

虽然显示此错误,但我仍在返回我的 identityId 和 Token 并成功调用需要经过身份验证的权限才能调用的 lambda 方法。我相信这与我的刷新方法有关,但我不确定。请帮我处理这个错误。

我的凭据提供商代码:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
id<AWSCognitoIdentityProvider> identityProvider = [[BusytimeAuthenticated alloc] initWithRegionType:AWSRegionUSEast1
identityId:nil
identityPoolId:@"EXAMPLEPOOLID"
logins:@{@"login.busytimeapp": [defaults objectForKey:@"username"]}
providerName:@"login.busytimeapp"
];

credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityProvider:identityProvider
unauthRoleArn:nil
authRoleArn:nil];

configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:self.credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
[[credentialsProvider refresh] continueWithBlock:^id(BFTask *task){
[self testAuth];
return nil;
}];

我的刷新方法:

- (BFTask *)refresh {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![self authenticatedWithProvider]) {
return [super getIdentityId];
}else{
NSDictionary *post = [[NSDictionary alloc] initWithObjectsAndKeys:
[defaults objectForKey:@"username"], @"username",
[defaults objectForKey:@"password"], @"password",
nil];
NSError *error;
NSData *postData = [NSJSONSerialization dataWithJSONObject:post options:0 error:&error];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"SOMEURL"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
__block BOOL isLogged = false;
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSDictionary *newJSON = [NSJSONSerialization JSONObjectWithData:data
options:0
error:&error];
isLogged = true;
if(!newJSON){
NSLog(@"DID NOT AUTHENTICATE");
}else{

self.identityId = [newJSON objectForKey:@"IdentityId" ];
self.token = [newJSON objectForKey:@"Token" ];
NSLog(@"Result: %@", newJSON);
}

}] resume];

return [super getIdentityId];

}
return [super getIdentityId];
}

最佳答案

这里的问题是您将登录映射中的登录提供商名称作为键传递。您不能对开发人员身份验证身份执行此操作。

相反,您应该在 map 中使用 Cognito 身份提供商名称 cognito-identity.amazonaws.com,就像它在 documentation 中所说的那样.这应该可以解决您的异常。

关于ios - Cognito 身份验证有效但显示错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33228309/

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