A CLI tool to authenticate multiple OpenAI accounts via OAuth (PKCE flow) and store the resulting tokens into an auth-profiles.json file used by OpenClaw agents.
- Generates a PKCE challenge and opens an OpenAI OAuth authorization URL in your browser.
- You paste back the callback URL (or raw authorization code).
- It exchanges the code for access/refresh tokens, extracts your email and account ID from the JWT, and writes a profile entry to
auth-profiles.json. - Repeat for as many accounts as you need.
A pure client-side version is available at https://thepagent.github.io/manytokens/
- Click "Open OpenAI Login" — a new tab opens the OAuth page
- Complete login; the browser redirects to
localhost:1455/auth/callback?code=... - Copy the full URL from the address bar and paste it back into the page
- Click "Exchange Token" — download
auth-profiles.json
No server required. All token exchange happens in the browser.
cargo build --release
./target/release/manytokens --openai [-o <output>]
./target/release/manytokens --refresh [-o <path>]
./target/release/manytokens --check [-o <path>] [--warn 24h] [--warn 6h] [--warn 1h]manytokens --openai -o auth-profiles.jsonOpens an OpenAI OAuth URL in your browser. Paste the callback URL back into the terminal. Repeat for multiple accounts.
manytokens --refresh -o auth-profiles.jsonNon-interactively refreshes all tokens using existing refresh tokens. Suitable for cron/systemd timers.
manytokens --check -o auth-profiles.json --warn 24h --warn 6h --warn 1hPrints expiry status for all profiles and warns when within specified thresholds.
Example session:
$ manytokens --openai
Open this URL in your browser:
https://auth.openai.com/oauth/authorize?response_type=code&client_id=<redacted...>
Paste the callback URL (or authorization code):
Follow the prompts — open the URL, complete login in the browser, paste the callback URL back into the terminal. When done, answer y to add another account or press Enter to finish.
Profiles are written to the path specified by -o (default: ./auth-profiles.json).
A .bak backup is created automatically before each save.
Each profile is keyed as openai-codex:<email> with type: oauth and includes access, refresh, and expires fields.