mercredi 3 juin 2015

iOS App use AWS SDK: GetCredentialsForIdentity failed

I use Cognito to create an Identity Pool and declare the credential in the delegate of my app,

AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc]
                                                      initWithRegionType:AWSRegionUSEast1
                                                      identityPoolId:@"us-east-1:XXXXX"];

AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
[[credentialsProvider getIdentityId] continueWithBlock:^id(BFTask *task){

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

    return nil;
}];

I have a Lambda Service in AWS, and I want to send a request to my lambda function, but I got this error:

AWSiOSSDKv2 [Error] AWSCredentialsProvider.m line:435 | __73-[AWSCognitoCredentialsProvider getCredentialsWithCognito:authenticated:]_block_invoke | GetCredentialsForIdentity failed. Error is [Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0x7fa4e96979f0 {NSErrorFailingURLStringKey=http://ift.tt/1Ftnhg0, NSErrorFailingURLKey=http://ift.tt/1Ftnhg0, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x7fa4e9450360 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"}]

Does anyone know the reason? It looks like I have the authority to invoke the function, but for some reason, it fails.

Thanks!




Aucun commentaire:

Enregistrer un commentaire