algotrade OAuth callback server

This page is the OAuth redirect target for Fyers, Upstox, and Angel One broker apps. When a broker sends a user back here (after they log in + 2FA on the broker's site), we capture the auth_code and either:

Start a broker login

Each link opens the broker's OAuth flow in a new tab. The broker will redirect back here when you finish. If you don't already have a pending login URL, the broker's landing page will guide you through the login + 2FA.

Login to Fyers Login to Upstox Angel (no OAuth — direct API TOTP)

Replace YOUR_APP_ID / YOUR_API_KEY with your actual Fyers/Upstox app credentials, and set the redirect_uri in your broker app's dashboard to match the https://algobot.in/cb/fyers/callback / https://algobot.in/cb/upstox/callback URLs shown here.

Callback endpoints (PR 52)

The recommended redirect URL (the one to set in your Fyers/Upstox app's developer console) is the common /cb/{broker} URL — it uses a signed state nonce and the main backend can match the in-progress ritual_run.

Fyers (recommended)
https://algobot.in/cb/cb/fyers
Upstox (recommended)
https://algobot.in/cb/cb/upstox
Angel (no OAuth)
https://algobot.in/cb/cb/angel

Legacy URLs (kept for backward-compat with the algobot.in PHP redirects — no signed state, no matching to ritual_run):

Fyers (legacy)
https://algobot.in/cb/fyers/callback
Upstox (legacy)
https://algobot.in/cb/upstox/callback
Angel (legacy)
https://algobot.in/cb/angel/callback
Health
/healthz

For ops / testing

This service is standalone — it can be deployed to the VPS as a systemd unit, or to any web host that supports Python + FastAPI. No algotrade database is needed.

CALLBACK_FORWARD_URL  = http://127.0.0.1:8000/internal/broker-callback
CALLBACK_STORAGE_DIR  = /var/lib/algotrade/callback
CALLBACK_BROKER_BASE_URL = https://algobot.in/cb