【发布时间】:2019-08-04 10:20:52
【问题描述】:
https://aws-amplify.github.io/docs/js/api#signing-request-with-iam 表示 AWS Amplify 提供了自动签署请求的能力..这与受 Cognito 限制的 API 网关 REST 请求相同吗?
auth.currentSession().then(token => {
console.log('>>>>', token.getIdToken().getJwtToken());
authToken = token.getIdToken().getJwtToken();
const myInit = { // OPTIONAL
headers: {
Authorization: authToken
},
response: true,
};
api.get(apiName, path, myInit).then(response => {
// Add your code here
console.log(response);
}).catch(error => {
console.log(error.response);
});
}
);
但我得到授权标头requires 'Credential' parameter. Authorization header requires 'Signature'
但在 Angular 中这不起作用,因为 Auth.currentSession() 无法编译
endpoints: [
{
name: 'test',
endpoint: 'https://xyz.execute-api.us-west-2.amazonaws.com/test',
custom_header: async () => {
// Alternatively, with Cognito User Pools use this:
return {Authorization: (await Auth.currentSession()).idToken.jwtToken};
}
}
]
}
【问题讨论】:
标签: aws-api-gateway aws-amplify