Skip to content

Instantly share code, notes, and snippets.

@rahulvramesh
Created August 6, 2020 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulvramesh/ad05a3cc6794d7261a358386d81286c5 to your computer and use it in GitHub Desktop.
Save rahulvramesh/ad05a3cc6794d7261a358386d81286c5 to your computer and use it in GitHub Desktop.

from stackoverflow

The AccessManager will fire off two events that you can hook into. Firstly, when a token is near expiry, it will fire a token expired event. Hook into that event and when you receive it, generate a new token from your server. You can then set that new token in the AccessManager.

const token = new AccessToken(
process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_API_KEY,
process.env.TWILIO_API_SECRET,
{ ttl: 86400 } //this is the line needed to be added for 24 huors , at the moment it is 1 hour only
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment