1. Help Center
  2. Technical Issue

401 error when trying to connect to the Websocket?

Here are the instances of what this error means:

  1. The API token was not present at all in the request query parameter `token`. The HTTP header `X-Websocket-Handshake-Error` contains the following message in this case: `You MUST provide a valid API Key as the token querystring parameter - /v1/stream?token=XYZ - token contains an invalid number of segments`
  2. The API token is malformed (could be incomplete, badly formatted, etc). *Usually* the HTTP header `X-Websocket-Handshake-Error` contains the following message in this case: `You MUST provide a valid API Key as the token querystring parameter - /v1/stream?token=XYZ - crypto/ecdsa: verification error`
  3. The API token has expired: The HTTP header `X-Websocket-Handshake-Error` contains the following message in this case: `You MUST provide a valid API Key as the token querystring parameter - /v1/stream?token=XYZ - token is expired by <Elapsed Time Since Expiration Human Format Dynamic>`

Our latest library will handle the token refresh for your automatically. If you are not using our latest library, be sure that you are handling the token refresh yourself.