51103: Twilsock: Token doesn't contain required grants section
ERROR
You see this error when the Access Token used to authenticate the client does not include a grants object in the JWT payload. Twilio Access Tokens must include at least one grant, and the grant must match the Twilio product your client is using.
- The JWT payload does not include a
grantsobject. - Your backend generated an Access Token without adding any product grant before calling
toJwt(). - Your Conversations token was created without a
ChatGrant. Conversations tokens require aChatGrant, and that grant must include your Conversation Service SID. - Your Sync token was created without a
SyncGrant. Sync tokens require aSyncGrantwith aserviceSidfor your Sync Service.
- Regenerate the token on your server and confirm the JWT payload includes a valid
grantsobject before you return it to the client. - Use a Twilio helper library to create the Access Token instead of assembling the JWT by hand.
- If you are using Conversations, add a
ChatGrantto the token and include the correct Conversation Service SID andidentity. - If you are using Sync, add a
SyncGrantto the token and include the correct Sync Service SID andidentity. - Decode the token and inspect its structure before initializing the client. If you need to verify the JWT format, use a JWT debugger such as jwt.io.