Skip to main content
Tokens are valid for ~1 hour. Fetching a new token on every request adds unnecessary latency and risks hitting rate limits. Production integrations should:
  1. Cache the access token in memory along with its expires_in value
  2. Refresh proactively when within 60 seconds of expiry
  3. On 401, invalidate the cache and fetch a new token, then retry the request once
The complete wrappers below handle all three cases and include gzip compression.