请找到以下代码。抛出请求中包含的安全令牌是无效错误。相同的凭据正在与Postman一起使用。我正在使用 react-native-aws-signature 。代码有什么问题?
var awsSignature = new AWSSignature();
let credentials = {
SecretKey: secret_key,
AccessKeyId: access_key
};
var options = {
path: '/PATH',
method: 'POST',
service: service',
headers: {
'X-Amz-Date': '20190205T105212Z',
'host': host,
'X-Amz-Security-Token': security_token
},
region: region,
body: '',
credentials
};
awsSignature.setParams(options);
var signature = awsSignature.getSignature();
var authorization = awsSignature.getAuthorizationHeader();
fetch(prefix + '/api_url', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'user_id': userId,
'X-Amz-Date': '20190205T105212Z',
'id_token': idToken,
'Authorization': authorization.Authorization
},
body: JSON.stringify(PostData),
})
.then((response) => console.warn('response', response))
.catch((error) => console.warn('error', error));