I use Spring-Lemon library for my spring boot project. I use a web front-end to my application. My question is, how to know if my auth token is about to expire? Documentation said a Get context operation should be used in this case to get a new token. But I did't find the way to find out when I should use this method to get a new token. Is there way to add the expiration date or the time remained to the responses, so my front-end would know that it should renew the token?
Asked
Active
Viewed 97 times
1 Answers
0
Knowing when it'll expire shouldn't be a problem, because you actually control it:
- By default, the expiration will be 10 days after you call
/context (See
LemonProperties
) - You can change it by setting a property
- You override the property be calling get-context with a parameter: /context?expirationMillis=123456

Sanjay
- 8,755
- 7
- 46
- 62
-
I see that, that's ok. But how should my front-end know it's time to call /context? I log in, save the token in local storage, 9 days pass then I reopen the site. I should renew the token, but how will the front-end know it? Should I store a date with it? If this is the case when I change the server side setting, I should change a front-end setting too for the right calculation. I thought there is a way to add the remaining time to responses, so the front-end would always know when it's about to refresh. (For example, if less then a day remained.) – Siriann Oct 22 '19 at 08:21