Sip*_*oza 11 authentication objective-c amazon-s3 amazon-web-services ios
我是移动设备上的新手.我正在尝试进行身份验证Amazon Cognito.我首先Credentials Provider使用自定义服务模型登录使用用户名,密码,平台和deviceToken - 然后我获取identityId,endPoint和token.有人告诉我,我需要换我回来的令牌,并刷新我的凭据,以便我经过身份验证才能AWS Cognito和S3.但是所有过程都令人困惑,并且有很多不同的例子.
我创建了一个SignInProvider,扩展了AWSSignInProvider以访问 - (void)登录:(void(^)(id result,NSError*error))completionHanlder; 我在我的登录方法中有我的令牌,端点和identityId.我对完成处理程序做了什么,接下来是什么呢.
@implementation SignInProvider
+(instanceType) sharedInstance{}
- (NSString) identityProviderName{}
- (AWSTask<NSString*>*) token{}
- (BOOL) isLoggedIn{}
- (NSSting*) userName{}
- (void) reloadSession{}
- (void) login: (void (^) (id result, NSError *error)) completionHanlder{
authRequest = [IMPCLDMobileAuthenticationRequest new];
[authRequest setToken:@"930fc1b56d8ca19a84500f9a79af71b65f60331f0242ce4395cdf41186443692"];
[authRequest setPassword:@"pin"];
[authRequest setUsername:@"example@email.co.za"];
[authRequest setPlatform:@"ios"];
serviceClient = [IMPCLDImpressionInternalMicroserviceClient defaultClient];
[[serviceClient mobileAuthenticationPost:authRequest] continueWithBlock:^id(AWSTask *loginTask)
{
//what to do here with my loginTask results (token, endpoint, identityId)
}
return nil;
}
Run Code Online (Sandbox Code Playgroud)
要交换/保存令牌,AWS您需要在您的continueWithBlock
[[serviceClient mobileAuthenticationPost:authRequest] continueWithBlock:^id(AWSTask *loginTask)
{
AWSSNSCreateEndpointResponse *response = loginTask.result;
AWSSNSSubscribeInput *subscribeRequest = [AWSSNSSubscribeInput new];
subscribeRequest.endpoint = response.endpointArn;
subscribeRequest.protocols = @"application";
subscribeRequest.topicArn = YOUR_TOPIC_ARN;
return [sns subscribe:subscribeRequest];
}] continueWithBlock:^id(AWSTask *task) {
if (task.cancelled) {
NSLog(@"Task cancelled");
}
else if (task.error) {
NSLog(@"Error occurred: [%@]", task.error);
}
else {
NSLog(@"Success");
}
return nil;
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
241 次 |
| 最近记录: |