-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we get Expire time along with tokens ? #178
Comments
By default Grant returns the tokens + the "response": ["tokens", "raw"] Inside the The expiration of your token can be calculated like this: var expires = Date.now() + (parseInt(raw.expires_in) * 1000) Then the condition to check if the token has expired is: if (Date.now() > expires) {
// you have to refresh it
} |
Another approach is to set |
Additionally, many services return a json web token as the access token. If you're using one of those services, you can skip the calculation by decoding the jwt and reading the expires timestamp directly. (In practice this doesn't matter much, since you'll want to refresh a couple minutes early to avoid getting messed up by skewed clocks or transport time.) |
Hi there, love the library! it's being so useful on a client project... my only issue is the next:
When I set response: "tokens" , I obviously get the tokens back, but no way of knowing when those tokens will expire... can we get a new option for
response
( could beexpiry
orexpiration
) to get back that?Thanks!
The text was updated successfully, but these errors were encountered: