William L.
William L.

Reputation: 3886

Best method to handle updating Twilio capability tokens?

I have a web app written in JavaScript & NodeJS that uses Twilio, when the user is online it allows incoming calls and outgoing calls. My question is; What's the best way to handle refreshing these tokens? Should I have a timer that automatically refreshes the token every X amount of minutes the user remains logged in. Is it safe to use the Twilio.Device.offline() callback to refresh the token? Any suggestions would be appreciated.

Upvotes: 0

Views: 109

Answers (1)

philnash
philnash

Reputation: 73055

Twilio developer evangelist here.

I recommend, as does the documentation, that you do use Twilio.Device.offline() to listen for events where the token expires and refresh at that point. That would be more resilient than setting a timer.

Upvotes: 1

Related Questions