Skip to content

chatgpt-oauth

Your users have ChatGPT subscriptions. This lets them spend those subscriptions inside your application instead of you paying per token — one OAuth flow, four language ports, one shared wire protocol.

Unofficial. Every port rides the Codex CLI’s public OAuth client and an undocumented ChatGPT backend. OpenAI can change or disable it without notice. Treat refresh tokens like passwords, never pool them across users, and keep an API-key or local-model fallback.

Start here

If you want toRead
Install and make a first requestyour port’s README — TypeScript, Python, Swift, Kotlin
Understand the custody model before you designConcepts
Know what an error means and what to doErrors
Store credentials for real usersStorage
Review this before shippingSecurity
Implement a fifth port, or check oneThe protocol
Work on this repoContributing
Deploy the hosted templateDeploying

The one rule

Every credential operation takes a subject that your application derives from its own authenticated session. Never from a request body, a query parameter, or a JWT claim.

// Right: the subject comes from your session.
const token = await auth.getAccessToken(session.userId);
// Wrong: the caller chose whose credentials to use.
const token = await auth.getAccessToken(request.body.userId);

Get this wrong and one user spends another user’s ChatGPT subscription. Everything else in these docs is downstream of it — see Concepts.

What maturity to expect

TypeScript runs in production in several applications. Python, Swift and Kotlin are ports of the same specification, checked against mocks and against each other, with no known production use yet. The repository README keeps a per-surface breakdown, and each port ships an examples/verify you can run against your own account.