Get session returns error : Access Token has expired
See original GitHub issueDo you want to request a feature or report a bug? Bug What is the current behavior? In some case on trying to get session aws Cognito return Access Token has expired. We have configured refresh token expiry days as 3650. So even if access token has expired we can refresh users Access token by using refresh token.
So to get refresh token I do cognitoUser.getSession() but this is returning response Access Token has expired due to some reason.
{ code: NotAuthorizedException, emailTried: j********@gmail.com, message: User j********@gmail.com : Access Token has expired, name: NotAuthorizedException }
Logic to refresh existing session: https://gist.github.com/stripathix/0f68b3a81379f39a80c8860cbf37a2aa
What is the expected behavior? Should give me old session from which I can get refresh token.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions? “amazon-cognito-identity-js”: “2.0.6”, “amazon-cognito-js”: “1.1.0”,
Not able to reproduce it but it does get logged a lot of time on error logger.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:14 (4 by maintainers)
I manage our auth module that gets refreshed token by accessing https://xxx.auth.us-east-2.amazoncognito.com/oauth2/token directly. It worked well for over 6 months but now it keeps getting the expired token from cognito.
@stripathix did you already address out this issue?
Correct me if I’m wrong, but doesn’t getSession automatically refreshes the accessToken?
https://github.com/aws/aws-amplify/blob/master/packages/amazon-cognito-identity-js/src/CognitoUser.js#L1160