ChatGPT OAuth Login
Instead of using an OpenAI API key, you can log in with your ChatGPT account via OAuth. This uses OpenAI's Codex backend at chatgpt.com.
Login Methods
LongerAgent supports two OAuth login methods:
Browser Login (PKCE) -- Recommended
Opens your default browser for one-click authentication. Best for local development.
longeragent oauthThe flow:
- A local callback server starts on
http://localhost:1455. - Your browser opens the OpenAI authorization page.
- Log in with your ChatGPT account and authorize LongerAgent.
- The browser redirects back to the local server to complete the flow.
Device Code -- Fallback
For SSH or headless environments where a browser is not available.
longeragent oauth
# Select "Device Code" when promptedThe flow:
- LongerAgent displays a URL and a code.
- Open the URL on any device and enter the code.
- Log in with your ChatGPT account.
- LongerAgent polls for completion and stores the token.
Token Storage
OAuth tokens are saved to ~/.longeragent/auth.json. Access tokens are refreshed automatically when they expire (with a 2-minute early-refresh window).
Managing OAuth
# Check login status
longeragent oauth status
# Log out (removes stored tokens)
longeragent oauth logoutUsing OAuth with the Init Wizard
When you run longeragent init, one of the provider options is OpenAI (ChatGPT Login). Selecting it triggers the OAuth login flow. LongerAgent then stores an internal OAuth marker for that provider and resolves the actual access token from ~/.longeragent/auth.json, so no API-key env var is needed. If the provider is already configured, you can switch back to it later with /model.
Once authenticated, the following models become available:
- GPT-5.2 Codex
- GPT-5.3 Codex
- GPT-5.4
Limitations
The ChatGPT OAuth backend has some differences from the standard OpenAI API:
- Requests are sent with
store: false(conversations are not stored on OpenAI's side). - Native web search is not available through this endpoint.
- Availability depends on your ChatGPT subscription plan.