story-teller-chat-gpt-login
v0.1.0
Published
Standalone CLI that authenticates a Story Teller user with ChatGPT (OpenAI Codex) via OAuth and stores the tokens in the backend.
Readme
chatgpt-login
Standalone CLI that connects a Story Teller account to ChatGPT (OpenAI Codex) via OAuth.
Why this exists
OpenAI's Codex OAuth client only allows the redirect URI
http://localhost:1455/auth/callback, so the login callback can only be
received on the user's own machine — a deployed backend can never catch it.
This tool runs that local listener: it opens the browser, captures the OAuth
callback on port 1455, then forwards the authorization code and PKCE
codeVerifier to the Story Teller backend. The backend performs the token
exchange and stores the credentials against your account
(POST /api/v1/auth/chatgpt/exchange).
Usage
You need:
- API base URL of your Story Teller backend (e.g.
https://api.example.com, orhttp://localhost:1455when running it locally). - Link token — a one-time token the app issues when you click
"Connect ChatGPT". The frontend calls
POST /api/v1/auth/chatgpt/link(Clerk-guarded) and shows you the ready-to-run command with the token baked in. The token is valid for ~15 minutes and is single-use.
Run it without installing (this is the command the app shows you):
npx story-teller-login --api https://api.example.com --token <link-token>Or via environment variables (the CLI prompts for anything missing):
STORYTELLER_API_URL=https://api.example.com \
STORYTELLER_TOKEN=<link-token> \
npx story-teller-loginFrom a checkout of this repo (e.g. local development):
npx ./tools/chatgpt-login --api https://api.example.com --token <link-token>
node tools/chatgpt-login/index.mjs # equivalentPublishing
The package is pure Node built-ins (no build step). To release a new version:
cd tools/chatgpt-login
npm version patch # bump version
npm publish # public by default (unscoped name)Flags
| Flag | Env | Description |
| --------------- | --------------------- | --------------------------------- |
| --api <url> | STORYTELLER_API_URL | Story Teller API base URL |
| --token <tok> | STORYTELLER_TOKEN | One-time link token from the app |
| -h, --help | | Show help |
Notes
- Requires Node 18+ (uses the built-in
fetch). No npm dependencies. - Port
1455must be free. If your local backend is already bound to it, stop it first (or run this on a different machine than the backend). - Link tokens expire after ~15 minutes and are single-use. If the exchange fails with "Invalid or expired link token", click "Connect ChatGPT" again to get a fresh command.
- Link tokens are stored in-memory on the backend, so they don't survive a restart and only work with a single backend instance.
