After login API I used 3 other APIs with jwt token coming from login API but one of the APIs returned an unauthorized error and my app stopped the login process.
I first thought the token was not properly set but then I copied the curl of that API and hit it in Postman it successfully returned.
this doesn’t come with same API every time for ex:
case 1
LOGIN API: SUCCESS
SOME API: 401
case 2
LOGIN API: SUCCESS
SOME API: SUCCESS
SOME OTHER API: 401
case 3
LOGIN API: SUCCESS
SOME API: SUCCESS
SOME OTHER API: SUCCESS
SOME OTHER API 2: 401
it only happens with api that runs continuously after login API.
It only occurs 1 out 5 times and 401 can be returned from any of 3 APIs which hit just after login API.
I didn’t change anything on the server side and it started happening recently.
How can I fix it?
2
Answers
Found a solution to this problem check here
Troubleshooting intermittent issues like this can be challenging, but here are some steps you can take to investigate and potentially resolve the problem:
Token Expiry and Refresh:
Token Handling:
API Rate Limiting:
Server-Side Logs:
Retry Mechanism:
Check for Server-Side Changes:
Network Issues:
Error Handling:
Update Dependencies:
Contact API Provider:
By systematically going through these steps, you may identify the root cause of the intermittent 401 errors and find a solution. If the issue persists, involving the API provider’s support can be beneficial.