【发布时间】:2017-08-10 03:33:21
【问题描述】:
我目前正在使用 USER-POOLS 授权器为我的 API 获取前 3 个令牌:
- idToken
- 刷新令牌
- 访问令牌
我想从这里请求凭据,以便能够向我已经设置的 API 网关发出 SigV4 请求,但首先我需要获取请求的凭据才能执行 SigV4。
在文档中我发现了这个:
// Set the region where your identity pool exists (us-east-1, eu-west-1)
AWSCognito.config.region = 'us-east-1';
// Configure the credentials provider to use your identity pool
AWSCognito.config.credentials = new AWSCognito.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:009xxxx ...',
});
// Make the call to obtain credentials
AWSCognito.config.credentials.get(function(){
// Credentials will be available when this function is called.
var accessKeyId = AWSCognito.config.credentials.accessKeyId;
var secretAccessKey = AWSCognito.config.credentials.secretAccessKey;
var sessionToken = AWSCognito.config.credentials.sessionToken;
});
令我惊讶的是,回调被调用了,但 - accessKeyId - 秘密访问密钥 - 会话令牌 都是空的。
我期待某种方法,我发送我的第一个 idToken,并基于此获得凭据,但看起来这一切都是在幕后想出来的?无论如何它对我不起作用。
【问题讨论】:
标签: amazon-web-services aws-sdk amazon-cognito aws-cognito