Headless OAuth: a single SDK call opens a browser, walks through OAuth, and returns aDocumentation Index
Fetch the complete documentation index at: https://docs.alterauth.com/llms.txt
Use this file to discover all available pages before exploring further.
grant_id usable immediately.
For CLIs, Jupyter notebooks, server-side agents bootstrapping a long-lived grant, or any environment without a frontend to host the Connect.js popup.
vault.connect()
Opens the user’s default browser to Alter Connect, polls until they finish OAuth, and returns the resulting grants:
results[0] carries the grant identity and account metadata.
- In Python:
grant_id,provider_id,account_identifier,scopes. - In TypeScript:
grantId,providerId,accountIdentifier,scopes.
vault.request(grant_id=...) in Python, vault.request({ grantId: ... }) in TypeScript).
Common options
| Argument | What it does |
|---|---|
providers=[...] | Limit which providers the end user can pick. Omit to allow any. |
grant_policy={...} | Set a max TTL on the resulting grant. |
timeout=300 | How long to poll. Defaults to 5 minutes. |
open_browser=False | Disable auto-open. The SDK prints the connect_url instead — useful for SSH sessions. |
vault.authenticate()
Opens the IDP’s sign-in flow and returns a JWT for the authenticated user. Use this when a script needs to act as a specific user against the JWT-identity flow without persisting a session.
When not to use this
- Production web apps → use Connect.js for popup flows or
create_connect_session()for redirect flows. Headless requires a local browser, which production servers lack. - End-user-driven flows already in a session → JWT identity (
provider="...", nogrant_idneeded).
Common pitfalls
- Calling from a remote container.
open_browser=Truewill fail. Setopen_browser=Falseand copy the printed URL into a local browser. - Long-running notebooks. The default 5-minute timeout can fire when left unattended. Pass
timeout=...for longer windows. - SSH session forwarding. SSH X11 forwarding is unreliable for OAuth — print the URL and visit it locally instead.
See also
- First 5 Minutes — uses
vault.connect()to bootstrap the demo grant. - Connect.js — the browser-popup alternative.
- SDK → Connect (Python) and SDK → Connect (TypeScript) — full reference for
connect(),authenticate(),create_connect_session().