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

51122: Twilsock: Authentication failed


ERROR: 51122

error-51122 page anchor
ERROR

Twilsock could not authenticate the client connection. This error usually means the access token is missing, invalid, expired, or does not match the Twilio product or identity your client is trying to use.

Possible causes

possible-causes page anchor
  • The client is using an expired access token.
  • The access token was signed with the wrong API Key SID or API Key Secret.
  • The token does not include the correct grant for the Twilio product you are using, such as Chat, Sync, or Notify.
  • The token identity does not match the user or client identity expected by your application.
  • The token was copied incorrectly, truncated, or modified before being sent to the SDK.
  • The client is attempting to connect to Twilsock before your application has retrieved a valid token from your backend.
  • Generate a new access token and make sure your client uses the latest token value.
  • Verify that your backend signs the token with a valid API Key SID and API Key Secret from the same Twilio account or subaccount your application uses.
  • Confirm that the token includes the correct grant for the SDK or product you are connecting to.
  • Check that the identity in the token is present, valid, and matches the identity your application expects.
  • Make sure your application refreshes tokens before they expire, especially for long-lived client sessions.
  • Inspect how the token is passed from your backend to the client and make sure it is not truncated, URL-encoded incorrectly, or stored with extra characters.
  • If you recently rotated credentials, update your token generation service to use the current API Key and Secret.

Additional resources

additional-resources page anchor