-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to refresh expired access tokens before submitting the original request? #87
Comments
I still wanted to follow up with the solution I eventually went for. Hope it will be useful for someone. And, of course, please critique! I created a custom middleware that runs before this (redux-axios-middleware) middleware. It basically intercepts every request and checks if the access token is still valid. If it's not, it will refresh the access token and make all other incoming requests wait. As I'm writing this, I realize it's probaby not super clean to release the blocked requests in random order, but it should be good enough for my use case. Here is the middleware code:
|
I ended up with something like that
|
Hi,
Thank you for this great library! I'm using an interceptor to add JWT access tokens to the requests in order to access our protected APIs. Now I'm trying to figure out what's the best way to deal with expired access tokens. Ideally, I would like to...
Could someone point me in the right direction? Is this generally feasible or should I rather focus on handling the
401
responses caused by the expired token? If it can be done, how would I go about it?Asking here as I think it may be relevant for others.
Thank you,
Johannes
The text was updated successfully, but these errors were encountered: