AWS iOS中的lambda函数问题Sdk
我是新来处理AWS Web服务的,我正在使用开放标识发送DeveloperAuthProviderName和Token在AWSCognitoCredentialsProvider类的登录字典中,然后在viecontroller中调用lambda功能和它给我下面的错误。我已经使用了CognitoSyncDemo App,并尝试通过pod导入所有框架,但结果相同。请帮我解决这个问题。AWS iOS中的lambda函数问题Sdk
AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:435 | __73- [AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:] _ block_invoke | GetCredentialsForIdentity失败。错误是[错误域= com.amazonaws.AWSCognitoIdentityErrorDomain代码= 7“无法完成操作(com.amazonaws.AWSCognitoIdentityErrorDomain错误7.)”UserInfo = 0x1700778c0 {__type = InvalidParameterException,message =请提供一个有效的公共提供者}]
这是Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 identityId:IdentityId identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
[[AWSServiceManager defaultServiceManager] setDefaultServiceConfiguration:configuration];
return YES;
}
这在的viewController在viewDidLoad中的代码。
-(void)setUpCredentials{
//initWithRegionType:CognitoRegionType identityId:IdentityId identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}
AZCDeveoper class inherit AWSEnhancedCognitoIdentityProvider class
AZCDeveloper * identity = [[AZCDeveloper alloc] initWithRegionType:CognitoRegionType identityId:IdentityId accountId:nil identityPoolId:CognitoIdentityPoolId logins:@{DeveloperAuthProviderName:Token}];
credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:CognitoRegionType
identityProvider:identity
unauthRoleArn:nil
authRoleArn:nil];
// [identity refresh];
}
这是在调用某个点击
-(void)lamdaInvoker{
AWSLambdaInvoker *lambdaInvoker = [AWSLambdaInvoker defaultLambdaInvoker];
NSLog(@"LamdaInvoker:%@",lambdaInvoker);
[[lambdaInvoker invokeFunction:@"Hello"
JSONObject:@{@"": @""}] continueWithBlock:^id(BFTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
if ([task.error.domain isEqualToString:AWSLambdaInvokerErrorDomain]
&& task.error.code == AWSLambdaInvokerErrorTypeFunctionError) {
NSLog(@"Function error: %@", task.error.userInfo[AWSLambdaInvokerFunctionErrorKey]);
}
}
if (task.exception) {
NSLog(@"Exception: %@", task.exception);
}
if (task.result) {
NSLog(@"Result: %@", task.result);
dispatch_async(dispatch_get_main_queue(), ^{
});
}
return nil;
}];
}
哎从你的问题lambda函数我会采取的做法是着眼于错误saysGetCredentialsForIdentity的部分。我对AWS也比较陌生,我认为有一半时间我遇到了一个错误,那是因为有一些关于证书的事情我做错了。我会确保IAM用户具有必要的凭据以调用lambda函数。
如果你认为你已经全部正确放置,那么我会确保你正确设置你的配置。
谢谢你答案,我解决了这个问题。 – user1068810
您需要提供您的代码。 – trojanfoe
请编辑您的问题,格式化您的代码和错误消息,并构建一个实际的问题。 – trojanfoe
任何帮助,将不胜感激。 – user1068810