Using AWS Cognito and aws-ios-sdk v.2.4.16 with developer identities

夙愿已清 提交于 2020-01-02 04:46:15

问题


I set up a lambda group of functions to do all my authentication. I connect from my app through the api gateway and then finally call GetOpenIdTokenForDeveloperIdentity(). This returns an identityId and token to my device through the gateway.

Next I follow this site's instructions (for Objective-C): http://docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html

Since I have the identityId and token I started with this:

DeveloperProvider.h

#import <AWSCore/AWSCore.h>

@interface DeveloperProvider : AWSCognitoCredentialsProviderHelper

@end

DeveloperProvider.m

@implementation DeveloperProvider
/*
 * Use the token method to communicate with your backend to get an
 * identityId and token.
 */

// Below gave me an error and changed to: - (AWSTask <NSString *> *) token
- (AWSTask <NSString*>) token
{
    //Write code to call your backend:
    //Pass username/password to backend or some sort of token to authenticate user
    //If successful, from backend call getOpenIdTokenForDeveloperIdentity with logins map 
    //containing "your.provider.name":"enduser.username"
    //Return the identity id and token to client
    //You can use AWSTaskCompletionSource to do this asynchronously

    // Added this in to the code
    NSString *identityId = @"IdentityIdFromGateway";
    NSString *token = @"TokenGotFromGatewayToo";

    // Changed below code from this:
    // Set the identity id and return the token
    // self.identityId = response.identityId;
    // return [AWSTask taskWithResult:response.token];
    // to this:
    self.identityId = identityId;
    return [AWSTask taskWithResult:token];
}

@end

I get two errors from above:

  1. In .h file I get 'Cannot find interface for AWSCognitoCredentialsProviderHelper'
  2. In .m file I get 'identityId is an assignment to a read-only property self.identityId'

I have reinstalled CocoaPods and reinstalled the aws-ios-sdk. I even cleaned out all old files and derived data.

Am I missing something? The end goal is to be able to have an authenticated user with access to call dynamodb and s3 from the app directly without using gateway and lambda anymore sine the user is authenticated. Thanks.

来源:https://stackoverflow.com/questions/41759794/using-aws-cognito-and-aws-ios-sdk-v-2-4-16-with-developer-identities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!