Answer the question
In order to leave comments, you need to log in
How to work with JWT refresh token?
Good day, gentlemen.
Please help, I can't figure out how JWT refresh tokens work.
What I understand at the moment:
1 - the user logs in, in exchange for his login / password he is given a pair of access token & refresh token
2 - on the client they are written in localStorage, and then in each request they are transmitted in the header
3 - until the access token is rotten - everything is fine.
4 - but what to do if it is rotten?
Here the server receives a refresh token and what should he do with it?
Suppose I wrote it to the database before giving it to the client, and now I checked it, it matches, everything is fine - I generate a new pair and give it to the header (something like set-new-jwt:xxxxxx)?
Or is it correct to give the front an answer that the token is rotten, and the front would request a new one?
And more questions:
1) How to deal with several devices with such a scheme? It turns out that the user will be logged out on an inactive device?
2) How to invalidate a token? Just blacklisting tokens (is this the right way?)? I don't see any other option but to change the secret key, but then it will log everyone out...
Thanks in advance for your help.
Answer the question
In order to leave comments, you need to log in
2 - on the client they are written to localStorage, and then in each request they are transmitted in the header
1) How to deal with several devices with such a scheme? It turns out that the user will be logged out on an inactive device?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question