我设置了一组lambda函数来完成我的所有身份验证.我通过api网关从我的应用程序连接,然后最终调用GetOpenIdTokenForDeveloperIdentity().这会通过网关将identityId和token返回给我的设备.
接下来,我按照本网站的说明(针对Objective-C):http: //docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html
因为我有identityId和令牌,所以我从这开始:
DeveloperProvider.h
#import@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*) token - (AWSTask ) 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
我从上面得到两个错误:
在.h文件中,我找到'无法找到AWSCognitoCredentialsProviderHelper的界面'
在.m文件中,我得到'identityId是对只读属性self.identityId的赋值
我重新安装了CocoaPods并重新安装了aws-ios-sdk.我甚至清理了所有旧文件和派生数据.
我错过了什么吗?最终目标是能够让经过身份验证的用户能够直接从应用程序调用dynamodb和s3,而无需使用网关和lambda,因为用户已经过身份验证.谢谢.