Skip to content

Token Expiry Handling

FYERS tokens expire daily and can be invalidated by logging in from another device. This playbook explains how to detect and recover safely.

What Happened

  • REST calls return auth errors (often code -8 or "token expired").
  • WS reconnect loops without receiving data.
  • History calls return empty data with "no_data" messages.

Why It Happens

  • FYERS sessions expire at the end of the trading day.
  • A new login on another device invalidates the previous token.

What To Check

  • logs/fyers_auth_errors.log for AuthError entries.
  • logs/fyers_ws_errors.log for auth-related disconnects.
  • Recent token timestamp in secrets/fyers_token.json.

What To Do Next

  1. Run fyers-auth to refresh the token.
  2. Restart the Store/Broker/DataFeed process.
  3. Confirm live data and order WS updates resume.

Safety Notes

  • Do not retry orders during auth failure.
  • Do not allow reconnect loops to run unattended; fix auth first.

Scenario Example

Scenario: Backtest history returns empty bars. What happened: - The cached token expired and history calls degrade into no_data. What to check: - logs/fyers_rest_errors.log and the FYERS SDK logs. What to do next: - Refresh the token and re-run the backtest.