AWS iOS Sdk中的Lambda函数问题 [英] Lambda function issue in AWS iOS Sdk

查看:180
本文介绍了AWS iOS Sdk中的Lambda函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是刚接触AWS Web服务的人,我正在与开放身份一起在AWSCognitoCredentialsProvider类的登录字典中发送DeveloperAuthProviderName和Token,然后在viecontroller中调用了lambda函数,并在下面给了我错误.我使用了CognitoSyncDemo App,并尝试通过pod导入所有框架,但结果是相同的.请帮助我.

I'm new to deal with AWS web services, i'm working with open-identity sending DeveloperAuthProviderName and Token in login dictionary of AWSCognitoCredentialsProvider class and then in a viecontroller i'm invoking a lambda funtion and its giving me error below. I have used CognitoSyncDemo App and also tried with importing all frameworks through pod but result is same. Please help me out of this.

AWSiOSSDKv2 [错误] AWSCredentialsProvider.m行:435 | __73- [AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:] _ block_invoke | GetCredentialsForIdentity失败.错误为[Error Domain = com.amazonaws.AWSCognitoIdentityErrorDomain代码= 7操作无法完成.(com.amazonaws.AWSCognitoIdentityErrorDomain错误7.)" UserInfo = 0x1700778c0 {__type = InvalidParameterException,message =请提供有效的公共提供者}]

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=0x1700778c0 {__type=InvalidParameterException, message=Please provide a valid public provider}]

这是Appdelegate.m

This is 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中的代码.

This is the code in viewDidLoad in a viewController.

-(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];

}

这是单击一次即可调用的lambda函数

This is the lambda function invoked on a certain click

-(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;
    }];


}

推荐答案

嘿,从您的问题开始,我将采用的方法集中于错误的GetCredentialsForIdentity部分.我对AWS也是相对较新,我认为有一半时间我遇到错误,这是因为我在做一些关于凭证的事情而做错了.我将确保IAM用户具有必要的凭据才能调用lambda函数.

hey from your question the approach I would take is focusing on the portion of the error that saysGetCredentialsForIdentity. I'm relatively new to AWS as well and I think that half the time I've encountered an error, it was because there was something about credentials that I was doing wrong. I'd make sure that the IAM user has the necessary credentials in order to invoke the lambda function.

如果您认为所有设置正确,那么我将确保正确设置配置.

If you think that you have that all correctly placed, then I'd make sure that you are setting up your configuration correctly.

这篇关于AWS iOS Sdk中的Lambda函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆