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.

Transaction cookies are not cleaned up when refresh token has expired

See original GitHub issue

Hi,

I’ve followed the advice in https://github.com/auth0/auth0-spa-js/issues/449 to allow us to handle when the refresh_token has expired. I manually create the client and then call checkSession, instead of using createAuth0Client. I’m using rotating refresh tokens and local storage.

If checkSession fails, I call .logout({localOnly: true}) to clear the token from local storage (otherwise I end up getting errors after re-login) and then immediately call loginWithRedirect.

The problem that I’m running into is that sometimes transaction cookies (a0.spajs.txs…) are being left behind. The cookies are all sent with the requests and it’s possible to end up with enough cookies that I start receiving 431 Request Header Fields Too Large errors which I can only resolve by clearing cookies.

With a long refresh_token expiry time, this is unlikely to become a problem (I’m testing with a very short token lifetime at the moment) but I’d like to make sure my implementation is cleaning up after itself.

Is there any way to clear out the old cookies? Is the fact that this can happen a bug in library or should I be handling it myself?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
stevehobbsdevcommented, Jun 15, 2020

Thanks. The only thing you can do when you get an invalid_refreshtoken error is to ensure that you put the user through the interactive login flow again to get a new token. Looks like you’re doing that by logging them out, but we could be doing a better job of cleaning that up ourselves when we throw that error. Let me put something in our backlog to fix that.

1reaction
freon27commented, Jun 15, 2020

Yes, the logout makes sure that the local storage is clean and doesn’t keep sending the expired refresh token (I think that might be a bug). Then the guard or interceptor handle forcing the login again.

Thanks for the help/explanation 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh Token expired with no apparent reason
A user couldn't retrieve an Access Token with their Refresh Token. Refresh Token is expired before the lifetime or without expiration at all....
Read more >
JWT (JSON Web Token) automatic prolongation of expiration
To refresh the token, your API needs a new endpoint that receives a valid, not expired JWT and returns the same signed JWT...
Read more >
Refresh Token Rotation and Reuse Detection in Node.js JWT ...
Node.js JWT Authentication is leveled up when you add refresh token rotation and reuse detection. We'll also be adding support for multiple ...
Read more >
API with NestJS #13. Implementing refresh tokens using JWT
This time, the refresh token is taken from the cookies and sent to the API. If it is valid and not expired, the...
Read more >
Token and key security :: SDKs - ForgeRock Backstage
The SDKs do not handle the refresh of SSO tokens. If an SSO Token has expired, the app needs to re-authenticate the user....
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