问题
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:
- In .h file I get 'Cannot find interface for AWSCognitoCredentialsProviderHelper'
- 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