40142: Token expired
token_expiredThe client's connection or request was rejected because the authentication token had expired. Each token has an expiry time that is set when it is issued.
What you should do
Usually nothing. Token expiry is a normal part of token authentication, and a client configured to renew its own tokens recovers without any intervention: it requests a fresh token and continues. A 40142 that appears briefly and then clears is expected, not a fault.
You only need to act when the error persists or surfaces to your application. That means renewal isn't happening — a configuration or auth-endpoint problem rather than the expiry itself, covered below.
Why it happens
When 40142 reaches your application instead of being handled silently, the cause is usually one of the following.
- No renewal mechanism is configured. Without
authUrlorauthCallback, the SDK has no way to obtain a replacement when a token expires. Configure one of these so renewal happens automatically. - The auth endpoint is unreachable or slow. If the
authUrlorauthCallbackfails or times out when the SDK tries to renew, the expired token is all that remains. Check that your token-issuing endpoint is reachable and returns a valid token promptly. - The token was issued with a very short lifetime. A small
ttlcauses tokens to expire sooner than expected, sometimes before the SDK renews them. Review thettlyou request against how long your clients actually need it. - The client clock is significantly skewed. A token can appear expired immediately after issue if the client's clock differs substantially from real time. Ensure the client clock is reasonably accurate.
What you'll see
The error is reported with code 40142 and HTTP status 401. The message is typically Token expired; some server paths report Access token expired.