AWS Amplify React Native,在将数据传递给请求时抛出403 InvalidSignatureException

问题描述 投票:1回答:1

我们仅为经过身份验证的身份创建API。所以唯一有效的用户可以访问它。只要任何请求正文中有数据,API就会抛出403 InvalidSignatureException。

我们还在原生Android上测试了API。它工作得很好。

我们的POST请求代码如下,

API.post(apiName, path, {body:{key:value}}).then(response => {
    consoloe.log(response);
}).catch(error => {
    consoloe.log(error);
});

我们已经关注GitHub和API网关上的所有内容,但没有得到适当的解决方案。

react-native aws-api-gateway aws-amplify
1个回答
0
投票

我也收到了InvalidSignatureException

我无法确定你的请求是什么问题,但我通过查看错误响应并发现我的区域错误(us_east_1而不是us-east-1)解决了我的问题。

请尝试以下方法:

API.post(apiName, path, {body:{key:value}}).then(response => {
    console.log(response);
}).catch(error => {
    console.log(error.response); // <--
});

在我的情况下,error.response是:

Response from API call

data.message下,描述了错误

© www.soinside.com 2019 - 2024. All rights reserved.