Lambda function issue in AWS iOS Sdk -
i'm new deal aws web services, i'm working open-identity sending developerauthprovidername , token in login dictionary of awscognitocredentialsprovider class , in viecontroller i'm invoking lambda funtion , giving me error below. have used cognitosyncdemo app , tried importing frameworks through pod result same. please me out of this.
awsiossdkv2 [error] awscredentialsprovider.m line:435 | __73-[awscognitocredentialsprovider getcredentialswithcognito:authenticated:]_block_invoke | getcredentialsforidentity failed. error [error domain=com.amazonaws.awscognitoidentityerrordomain code=7 "the operation couldn’t completed. (com.amazonaws.awscognitoidentityerrordomain error 7.)" userinfo=0x1700778c0 {__type=invalidparameterexception, message=please provide valid public provider}]
this appdelegate.m
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point 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; }
this code in viewdidload in 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]; }
this lambda function invoked on 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; }]; }
hey question approach take focusing on portion of error saysgetcredentialsforidentity. i'm relatively new aws , think half time i've encountered error, because there credentials doing wrong. i'd make sure iam user has necessary credentials in order invoke lambda function.
if think have correctly placed, i'd make sure setting configuration correctly.
Comments
Post a Comment