J
J
Jedi2019-02-11 02:37:45
JSON Web Token
Jedi, 2019-02-11 02:37:45

How to competently implement JWT Token Refresh?

Good morning!
I'm working on implementing a small blog in React and Laravel. Now implemented a simple authorization and registration, everything works correctly.
For Laravel, I use the Tymon/JWT library , which provides the JWT capability. Upon authorization, I receive a token that has 1 hour left to live. In the settings, this time can be changed, you can even set it to infinite.
Questions from a teapot in JWT:
If the token lives only 1 hour, let's say that a certain user logged in, used it and put his laptop away for a couple of hours. When he turns on the laptop, he will have to log in again. It turns out that this is exactly the case.
To get a new token (Refresh Token) you need to have a valid one (not expired) when sending a request.
Can you please explain to me how Refresh Token works? How long should a token live? How to implement all this correctly? and... when should the token be refreshed?
Explain in simple language for you.
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mi7teR, 2019-02-11
@Mi7teR

https://gist.github.com/zmts/802dc9c3510d79fd40f9d...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question