首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >创建私有Amazon API网关

创建私有Amazon API网关
EN

Stack Overflow用户
提问于 2016-08-11 16:03:58
回答 1查看 339关注 0票数 0

我想为我的应用程序创建一个只有我的应用程序才能访问的api。我已经将AWS Cognito标识添加到我的appDelegate中,如下所示:

代码语言:javascript
复制
 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的应用程序可以访问我的应用程序接口?是否需要保存此id并在访问api时使用?

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2016-08-15 12:51:08

使用'AWS_IAM‘授权保护应用编程接口将需要使用同一AWS帐户中的凭据对请求进行签名。除此之外,如果您控制了帐户,那么您应该能够通过使用API Gateway操作和资源设置细粒度策略来确保只有Cognito角色具有访问权限。

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

应用程序应该在经过身份验证时接收Cognito凭据,因此您将在API Gateway SDK中使用它。生成的SDK有iOS版、安卓版和JavaScript版。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38890643

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档