【发布时间】:2018-01-22 08:14:01
【问题描述】:
使用 Cognito 用户池成功进行身份验证后,我获得了访问 aws 资源的临时凭据
var akey='';
var skey='';
var st='';
AWS.config.credentials.get(function (err) {
akey = AWS.config.credentials.accessKeyId;
skey = AWS.config.credentials.secretAccessKey;
st = AWS.config.credentials.sessionToken;
var identityId = AWS.config.credentials.identityId;
});
使用我调用的那些使用 IAM 授权的 API 的凭据
function ViewMyBookings_With_Credentials() {
debugger;
var apigClient = apigClientFactory.newClient({
accessKey: akey,
secretKey: skey,
sessionToken: st,
region: 'ap-south-1'
});
var params = { };
var body = ''; // Get Request
var additionalParams = { };
apigClient.mybookingsGet(params, body, additionalParams)
.then(function (result) {
//This is where you would put a success callback
alert(result.data);
}).catch(function (result) {
debugger;
alert(result.data);
//This is where you would put an error callback
});
}
选项请求成功,我得到了 200 OK 但是对于实际请求显示 CORS 错误,我确信 CORS 没有问题。 显示响应标头
x-amzn-ErrorType:UnrecognizedClientException X-Cache:来自云端的错误
我在 AWS 文档中搜索了此内容,但未收到任何正面回复。
One Question addressing similar issue
但答案不正确/不完整,请让我知道我缺少什么。
【问题讨论】:
-
“正在显示响应标头”...包括 CORS 标头?
标签: javascript amazon-web-services lambda aws-api-gateway amazon-cognito