这个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'
但在角度,这不起作用,因为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};
}
}
]
}
已解决有请求URL的拼写错误它必须是/items/:test
其中test是发电机中的分区名称,也是
headers: {
Authorization: token
},
不需要:
https://github.com/aws-amplify/amplify-js/issues/2810#issuecomment-470213459