This will usually occur if you haven't provided an authUrl or authCallback in your clientOptions when instancing the Ably REST or Realtime library. 

Tokens have a set expiration time, and once that time has been passed the token will no longer be valid for communicating with Ably. If you make use of authUrl or authCallback, a new token will automatically be requested prior to the current one expiring, ensuring that the library can continue to operate.

Further reading: