Contents
How do I set token time?
You can change the access token lifetime using the Auth0 Dashboard. Go to Dashboard > Applications > APIs and click the name of the API to view. Locate the Token Expiration (Seconds) field, and enter the appropriate access token lifetime (in seconds) for the API. Default value is 86,400 seconds (24 hours).
What is token time?
By default, all tokens have a system-defined time-to-live of 7 days (604800 seconds). Note that Token ttl is specified in milliseconds, but when a token is created, the API response will return the ttl in seconds.
What happens when token is refreshed in RESTful API?
In this case the client will immediately call the renew endpoint, if it returns 200 then the token is refreshed, but if renew also returns 401 then it means that the client is out of the system. Which of the two above alternatives would you recommend?
What happens when you renew a Web Token?
The new token will replace the existing in future calls. As you can see, this reduces the frequent refresh token requests. If user closes the browser/app before the renew token call is triggered, the previous token will expire in time and user will have to re-login.
When to return an HTTP 401 code when token has expired?
Return an http 401 code (unauthorized) if the session has become invalid or return a 412 code (precondition failed) when the token has expired and it’s time to call the renew endpoint, which will return a 200 (ok) code. Return 401 for signaling that either the session is invalid or the token has expired.
Can a token be invalid before the session expires?
It’s possible that an user’s API session becomes invalid before the token expires, hence all of my endpoints start by checking that: 1) the token is still valid and 2) the user’s session is still valid. There is no way to directly invalidate the token, because the clients store it locally.