API.get Sometimes gets 403.
See original GitHub issueDescribe the bug Suddenly the response of API.get gets 403. (signature doesn’t match) After once I got 403, I keep getting 403 ever. It happens sometimes, I mean few times a day. I researched about this problem. I noticed header is different with success one and failed one.
difference
- existing of host
- actually
Accept
but in below example , these are same, because I specified clearly.
success one
{
'User-Agent':'aws-amplify/1.0.28 react-native',
Accept:'application/json',
host:'***MASK***',
'x-amz-date':'20190701T022854Z',
'X-Amz-Security-Token':'***MASK***',
Authorization:'AWS4-HMAC-SHA256 Credential=***MASK***/20190701/us-east-1/execute-api/aws4_request, SignedHeaders=accept;host;user-agent;x-amz-date;x-amz-security-token, Signature=05bb4d19eae6fafbdf1e478a38010745cf0862c78fe962f672dc7e2bf5b03456'
}
failed one
{
Accept:'application/json',
'User-Agent':'aws-amplify/1.0.28 react-native',
'x-amz-date':'20190701T022729Z',
'X-Amz-Security-Token':'***MASK***',
Authorization:'AWS4-HMAC-SHA256 Credential=***MASK***/20190701/us-east-1/execute-api/aws4_request, SignedHeaders=accept;host;user-agent;x-amz-date;x-amz-security-token, Signature=c233e9ec17f1522006a2f3d29a28160b81ce184cee806a10f039f1c3f0dcee85'
}
To Reproduce Steps to reproduce the behavior:
- I call API like this.
const path = `MASK`;
const option = {
headers: { Accept: 'application/json' }
};
const res = await API.get('MASK', path, option);
- Keep using app, but I don’t know when it is occurred.
- Suddenly a API.get failed.
Expected behavior I expect that same request generates same request header. And it works correctly.
Screenshots No screenshots.
Smartphone (please complete the following information):
- Device: HUAWEI ANE-LX2J
- OS: Android 9
- Browser React Native
- Version React Native 0.59.8
Additional context Nothing special.
Sample code
const path = `MASK`;
const option = {
headers: { Accept: 'application/json' }
};
const res = await API.get('MASK', path, option);
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Fix 403 Forbidden errors when connecting to API Gateway ...
The HTTP 403 Forbidden error most commonly occurs when private DNS is enabled for an API Gateway interface VPC endpoint that's associated ...
Read more >403 Forbidden Error: What It Is and How to Fix It - Airbrake Blog
The 403 Forbidden Error is an HTTP response status code that indicates an identified client does not have proper authorization to access the ......
Read more >getting 403 error while trying to connect an API - Stack Overflow
I'm trying to connect an private api with curl but i got the following error: 403 - Forbidden: Access is denied. You do...
Read more >Error 403: When Running Token API - Data Actions
The request to the target service is returning the 403. You'll need to contact the owner of that service to investigate why it's...
Read more >403 Forbidden error: What it is and how to fix it - Allconnect.com
Reasons why you might get a 403 error · The content is private – The content owner has designated it as private. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@manueliglesias You were at some point looking into this issue, but nothing seems to have come out of that. I think it’s pretty clear now, that the main reason for this happening from all these reports, is clock drift and that should be possible to correct/fix in the library. Could you work on this?
Folks I am facing exactly the same problem with React Native and AWS Cognito Developer Identities. The issue occurs randomly in some cases and is not consistently reproducible.
Authentication keeps failing until app is force terminated. I am seeing about 30% of the requests fail due to this issue. Seems like something gets cached in the SDK. The same is cleared by terminating the app and reinitializing the SDK. This is having a major customer impact.
Different responses for exactly the same request as below:
Successful request config from server success response
"config": { "url": "https://*****", "method": "get", "data": null, "headers": { "Accept": "application/json, text/plain, */*", "User-Agent": "aws-amplify/1.0.28 react-native", "sessionToken": "****", "x-amz-date": "20190801T131618Z", "X-Amz-Security-Token": "*****", "Authorization": "AWS4-HMAC-SHA256 Credential=*****/20190801/ap-south-1/execute-api/aws4_request, SignedHeaders=host;sessiontoken;user-agent;x-amz-date;x-amz-security-token, Signature=*****" }, "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "responseType": "json", "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1 }
Amplify debug rest-client log for Successful
Signer - POST /**** content-type:application/json; charset=UTF-8 host:****.execute-api.ap-south-1.amazonaws.com sessiontoken:***** user-agent:aws-amplify/1.0.28 react-native x-amz-date:20190801T131618Z x-amz-security-token:**** content-type;host;sessiontoken;user-agent;x-amz-date;x-amz-security-token ****
Failed request config from server error response caught in exception
"config": { "url": "https://****", "method": "post", "data": "{}", "headers": { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json; charset=UTF-8", "User-Agent": "aws-amplify/1.0.28 react-native", "sessionToken": "*****", "x-amz-date": "20190731T101110Z", "X-Amz-Security-Token": "******", "Authorization": "AWS4-HMAC-SHA256 Credential=******/20190731/ap-south-1/execute-api/aws4_request, SignedHeaders=content-type;host;sessiontoken;user-agent;x-amz-date;x-amz-security-token, Signature=****" },
Amplify debug rest-client log for Failed
Signer - POST /***** content-type:application/json; charset=UTF-8 host:****.execute-api.ap-south-1.amazonaws.com sessiontoken:***** user-agent:aws-amplify/1.0.28 react-native x-amz-date:20190731T101131Z x-amz-security-token:**** content-type;host;sessiontoken;user-agent;x-amz-date;x-amz-security-token *****
@sekitaka were you able to fix it? I do see the accept header in the config in the response and it is not present in the Signer Amplify debug log. This applies to both successful and errored requests. Just make sure you are looking at the same data.
So the reason for failure is not clear.