Adjetey Octavius
Adjetey Octavius

Reputation: 51

Keeping User Logged In With JWT

Please I would like to know how do I keep a user logged in using JWT through a REST API. Because the token given by JWT expires within a particular time frame and within this time frame it could be possible that the user is still on the app.

I am thinking of allowing the client side application to make asynchronous requests when the token expires. But the one would also make the client side stall a bit because the token is invalid.

Upvotes: 1

Views: 58

Answers (1)

inf3rno
inf3rno

Reputation: 26137

If you have this kind of expiration time, you must renew the token before it expires. You need to add this feature to the client side code. It will be hard with a sync client. Another way is renewing it when the sync client runs on the error message about the expiration and resend the last request, so it can be added to the error handling. If so, then it can be generalized in the error handling code.

Upvotes: 1

Related Questions