40170: Token callback failed

error_from_client_token_callback

Authentication could not complete because the client's own token-request mechanism, its authCallback or authUrl, returned an error instead of a token or token request. The failure originates in the application's auth logic or endpoint, not within Ably.

What you should do

Fix your token-request mechanism. The SDK reached your authUrl or authCallback but got an error back instead of a token, so start from the accompanying message and check your auth endpoint. Common problems are a slow endpoint that times out, a missing Content-Type header, or a response whose content type the SDK can't parse.

Why it happens

The client's own auth logic failed. The SDK invoked the configured authUrl or authCallback to obtain a token and got an error, so the cause lies in your application's auth endpoint or callback rather than in Ably. It can be a network error or timeout reaching the endpoint, or a response the SDK can't use.

What you'll see

The error is reported with code 40170 and HTTP status 401. Messages include authUrl response is missing a Content-Type header and authUrl responded with unacceptable Content-Type .... An authUrl must return application/json, text/plain, or application/jwt.