cdu*_*dub 5 objective-c amazon-web-services ios amazon-cognito aws-sdk-ios
我设置了一组lambda函数来完成我的所有身份验证.我通过api网关从我的应用程序连接,然后最终调用GetOpenIdTokenForDeveloperIdentity().这会通过网关将identityId和token返回给我的设备.
接下来,我按照本网站的说明(针对Objective-C):http: //docs.aws.amazon.com/cognito/latest/developerguide/developer-authenticated-identities.html
因为我有identityId和令牌,所以我从这开始:
DeveloperProvider.h
#import <AWSCore/AWSCore.h>
@interface DeveloperProvider : AWSCognitoCredentialsProviderHelper
@end
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我从上面得到两个错误:
我重新安装了CocoaPods并重新安装了aws-ios-sdk.我甚至清理了所有旧文件和派生数据.
我错过了什么吗?最终目标是能够让经过身份验证的用户能够直接从应用程序调用dynamodb和s3,而无需使用网关和lambda,因为用户已经过身份验证.谢谢.
| 归档时间: |
|
| 查看次数: |
221 次 |
| 最近记录: |