首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取AWS访问和密钥

获取AWS访问和密钥
EN

Stack Overflow用户
提问于 2020-08-25 23:32:58
回答 1查看 57关注 0票数 0

Infra类似于具有处理程序Lambda函数的API Gateway。我们已经为3个客户端创建了3个IAM用户,客户端通过提供访问和密钥来执行API网关。我想获取访问权限和密钥来识别用户。下面的代码(在lambda中)帮助我们获取用户详细信息。

代码语言:javascript
复制
AWSCredentialsProvider credProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials("accessKey","secretKey"))
AmazonIdentityManagementClientBuilder.standard().withCredentials(credProvider).build()

如何获取访问权限和密钥?处理函数中的上下文对象仅提供认知身份对象,但我一直期望在api调用过程中使用具有访问权限和密钥的IAM身份对象。

EN

回答 1

Stack Overflow用户

发布于 2020-12-04 15:14:53

实施RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent>。对于每个传入的请求事件,您将在APIGatewayProxyRequestEvent中获得以下详细信息

代码语言:javascript
复制
requestEvent.getRequestContext().getIdentity() 

包含

代码语言:javascript
复制
    private String cognitoIdentityPoolId;
    private String accountId;
    private String cognitoIdentityId;
    private String caller;
    private String apiKey;
    private String sourceIp;
    private String cognitoAuthenticationType;
    private String cognitoAuthenticationProvider;
    private String userArn;
    private String userAgent;
    private String user;
    private String accessKey;

如您所见,您将在userARN中获得userID以及accessKey。

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

https://stackoverflow.com/questions/63582305

复制
相关文章

相似问题

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