31204: Invalid JWT token.
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.
- 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.