【发布时间】:2016-12-17 20:31:27
【问题描述】:
我想为我的应用创建一个只能由我的应用访问的 api。我已将 AWS Cognito 身份添加到我的 appDelegate 中,如下所示:
AWSCognitoCredentialsProvider *credentialsProvider = [[DeveloperAuthenticationProvider alloc] initWithRegionType:AWSRegionUSEast1 identityPoolId:@"poolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
__block NSString *cognitoId = nil;
// Retrieve your Amazon Cognito ID
[[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task)
{
if (task.error)
{
NSLog(@"Error: %@", task.error);
}
else
{
// the task result will contain the identity id
cognitoId = task.result;
}
return nil;
}];
我如何使用返回的 gonitoId 来确保这是唯一具有该 id 的应用程序可以访问我的 api?访问api时需要保存这个id使用吗?
谢谢。
【问题讨论】:
标签: ios amazon-web-services amazon-iam amazon-cognito aws-api-gateway