How long a token lasts, how to check it is still valid, and what to do when it expires.
How long a token lasts
An access token stays valid until the daily server restart (start of day) at about 4:00 AM IST. Logging in again issues a new token and the old one stops working. To renew, run the OAuth login again.
Lifetime
The login response includes expires_in. Treat it as an absolute Unix time, not a number of seconds. Compare it with the current time. Details: Token & session lifetime.
Checking a session
Call User Details at start-up. an HTTP error with an empty body, or stat: Not_Ok with a session message means: log in again.
Renewing
Detect the failure (HTTP 403, or a Session Expired message).