This means your auth credentials are in some way invalid. The specific text of the error may give more details.
Some examples of specific 40101 errors include:
40101 Request mac does not match
This indicates that a signed token request, sent to Ably to request a token, is not valid: the cryptographic signature isn't what it should be.
Things you should check which may be causing this problem:
- The api key used to instantiate the library that generates the token request is not correct. Double check that you haven't accidentally clipped off the last letter or two, or added a space at the end.
- Make sure the token request JSON has not been altered. A valid token as JSON looks like this:
{
"keyName":"I2E_JQ.r_aOYg", /* String value, matches key used when instancing lib */
"clientId":"foo", /* optional, must be a string value, NOT case clientId, not client_id */.
"ttl":43200000, /* integer in milliseconds, NOT seconds */
"timestamp": 1500452987683, /* integer, milliseconds since the epoch, NOT seconds */
"capability":"{\"*\":[\"*\"]}", /* This should be stringified JSON, not actual JSON */
"nonce":"5137f32abdaccfcef49d98451da018d0", /* string value generated randomly by the lib */
"mac":"g6vNUDFWhvUoZABYX2HiKoFh7bEYG394oJlhqNxTno0=" /* the Mac in question generated from the other values & the secret part of your API key */
}
40101 Invalid clientId for credentials
This indicates that the clientId the Ably SDK has been instantiated with doesn't match the clientId in the access token used in a connection to Ably.
Things you should check which may be causing this problem:
- Check your client code to see if a clientId is provided in the client options of the Ably constructor
- Check the code used to generate a token. If a clientId is used in generating the token and one is also provided to the client constructor they will need to match.
- A clientId is immutable so cant be changed on an existing connection
- If using JWT authentication make sure the clientId is set in x-ably-clientId
If you've gone through the list above and are still getting this error, try to get a debug-level log of the generation of a token request, and contact us for more help.