Skip to contentSkip to navigationSkip to topbar
Page toolsOn this pageProducts used
Looking for more inspiration?Visit the

31204: Invalid JWT token.


ERROR: 31204

error-31204 page anchor
VOICE
ERROR

The Twilio Voice SDK reports this error when the JSON Web Token presented for authentication is invalid. Voice SDK authorization errors list 31204 as "Invalid JWT token," and Voice Access Tokens are the JWTs used to authenticate Voice SDK clients.

Possible Causes

possible-causes page anchor
  • The Access Token isn't a properly formed JWT, so it can't be parsed or validated by Twilio.
  • The Access Token was generated with an incorrect Account SID or API Key, making the issuer or subject invalid for Twilio's verification.
  • The token is missing required Voice SDK fields such as an identity grant and a VoiceGrant.
  • Regenerate a new Voice Access Token on your server using your Account SID and a valid API Key and Secret, and include the required VoiceGrant and identity before passing it to the SDK.
  • Decode and inspect the token to verify header, payload, signature, and grants, using a JWT decoder as recommended in the Voice SDKs documentation.
  • Verify the token's issuer and subject map to the correct API Key and Account SID to satisfy Twilio's validation requirements.
  • Use Main or Standard API Keys to create Access Tokens, as Restricted API Keys aren't supported for Access Token generation.

Additional resources

additional-resources page anchor