40005: Invalid API key or token
invalid_credentialAn API key or token supplied with the request could not be read because it was not in the expected form. This is distinct from a key or token that is well-formed but unauthorized.
What you should do
Check the API key or token the client was configured with. The value couldn't be read at all, so the fix is to supply a correctly-formed credential, not to adjust its permissions. Copy the key from the Ably dashboard again in case it was truncated or picked up stray whitespace.
Why it happens
The credential supplied was not in the expected form, so it couldn't be parsed. Common causes are a key or token that was truncated, had characters added or removed, or was passed in the wrong field. This is distinct from a well-formed credential that is rejected as unauthorized.
What you'll see
The error is reported with code 40005 and HTTP status 400. The message names the unreadable value, for example Invalid key in request: ... or Invalid accessToken in request: ....