51121: Twilsock: Token expiration time exceeds maximum
ERROR
This error occurs when Twilsock receives an Access Token whose exp value is beyond the allowed lifetime. Twilio Access Tokens are short-lived JWT credentials, and their maximum age is 24 hours.
- Your application generated the token with a
ttlvalue greater than 86400 seconds. Twilio interpretsttlin seconds and limits Access Tokens to 24 hours. - The token's
expclaim is set more than 24 hours after issuance. Twilio usesexpas the expiration timestamp and limits token age to 24 hours. - Your token generation logic used the wrong time unit or an incorrect timestamp calculation, which caused the expiration to exceed the allowed range. Access Token lifetime values are expressed in seconds.
- Generate a new Access Token with a
ttlof 86400 seconds or less. Use the shortest lifetime that fits your application. - If you set claims directly, verify that
expis no more than 24 hours afteriatand that all time values are in seconds. - Use a Twilio helper library to create the token so the
JWTstructure and claims are generated correctly. Twilio recommends helper libraries when troubleshooting invalid Access Tokens. - For long-lived SDK sessions, refresh the token before it expires instead of extending a single token beyond the 24-hour limit. Conversations SDK clients can request a new token and call
updateTokenbefore expiration.