How batpool/upstox-totp works
Upstox TOTP is a Python SDK and CLI for turning account credentials and a TOTP secret into an Upstox OAuth access token. The main workflow configures a client, performs authorization-dialog lookup, OTP generation and verification, PIN-based 2FA, OAuth approval, then exchanges the authorization code for a token. The graph also captures the CLI and the shared request, response-model, error, and logging layers. Relationships are grounded in the sampled client, API, CLI, and model code; README claims about refresh/storage and trading integrations are not represented as implemented components because their source is not shown.
Main entry points: app_token.py Token Workflow · client.py Client · base.py HTTP Request Layer · cli.py CLI Commands
Components 14
SDK Interfaces
- Python SDK
src/upstox_totp/__init__.py - CLI Commands
src/upstox_totp/cli.py
Authentication Flow
- Token Workflow
src/upstox_totp/_api/app_token.py - Access Token
Client Runtime
- Client
src/upstox_totp/client.py - TOTP Generator
src/upstox_totp/client.py - HTTP Request Layer
src/upstox_totp/_api/base.py
Shared Support
- Configuration Models
src/upstox_totp/models.py - Auth Response Models
src/upstox_totp/models.py - Error Handling
src/upstox_totp/errors.py - Logging
src/upstox_totp/logging.py
Other components
- Developer
- CLI User
- Upstox Services
Connections 21
- Developer → Python SDK: uses
src/upstox_totp/__init__.py - CLI User → CLI Commands: runs
src/upstox_totp/cli.py - Python SDK → Client: exports
src/upstox_totp/__init__.py - CLI Commands → Client: creates
src/upstox_totp/cli.py - CLI Commands → Token Workflow: requests token
src/upstox_totp/cli.py - Client → Configuration Models: loads
src/upstox_totp/client.py - Client → TOTP Generator: generates
src/upstox_totp/client.py - Client → Token Workflow: creates
src/upstox_totp/client.py - Token Workflow → HTTP Request Layer: sends requests
src/upstox_totp/_api/app_token.py - HTTP Request Layer → Client: uses session
src/upstox_totp/_api/base.py - Token Workflow → TOTP Generator: gets code
src/upstox_totp/_api/app_token.py - Token Workflow → Auth Response Models: validates responses
src/upstox_totp/_api/app_token.py - HTTP Request Layer → Auth Response Models: parses JSON
src/upstox_totp/_api/base.py - Token Workflow → Upstox Services: authenticates
src/upstox_totp/_api/app_token.py - HTTP Request Layer → Upstox Services: HTTP exchange
src/upstox_totp/_api/base.py - Token Workflow → Access Token: returns token
src/upstox_totp/_api/app_token.py - HTTP Request Layer → Error Handling: raises on failure
src/upstox_totp/_api/base.py - Token Workflow → Error Handling: raises validation
src/upstox_totp/_api/app_token.py - Client → Error Handling: raises configuration
src/upstox_totp/client.py - Client → Logging: sets level
src/upstox_totp/client.py - HTTP Request Layer → Logging: logs requests
src/upstox_totp/_api/base.py