创build一个私有的Amazon API网关

我想为我的应用程序创build一个只能通过我的应用程序访问的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? 我需要保存这个ID并在访问API时使用它?

谢谢。

使用“AWS_IAM”授权保护API将要求使用相同AWS账户中的凭证对请求进行签名。 过去,如果您在控制帐户,那么您应该能够通过设置API Gateway操作和资源的细粒度策略来确保只有Cognitoangular色才能访问。

http://docs.aws.amazon.com/apigateway/latest/developerguide/permissions.html#api-gateway-calling-api-permissions

应用程序应在validation时接收Cognito凭据,以便在API网关SDK中使用。 生成的SDK可在iOS Android和JavaScript中使用。

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk.html