question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get session returns error : Access Token has expired

See original GitHub issue

Do 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
leonachan1commented, Apr 3, 2019

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?

1reaction
luisgurmendezcommented, Jun 27, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Access token session has expired, please reauthorize ...
Hi, I get this error from time to time: Error: Access token session has expired, please reauthorize access token. Previously I could solve...
Read more >
How to fix "Error: Access token has expired or is not yet valid ...
It is a short-lived access token that is only valid for an hour I think. You need to refresh the token before it...
Read more >
Connected App, request with access token returns an error
Is there a way to get new access token when current session get expired without using Connected App? 0 · Connected App client...
Read more >
Troubleshoot AWS STS security token expired errors when ...
I tried to assume an AWS Identity and Access Management (IAM) role by using the AWS Command Line Interface (AWS CLI).
Read more >
Authentication Failed. Your session token has expired or is no ...
Has your Team been suspended or has your Trial finished? This error is typical of cases where the Team is no longer valid....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found