auth.md +41 −1
9 9
10Codex cloud requires signing in with ChatGPT. The Codex CLI and IDE extension support both sign-in methods.10Codex cloud requires signing in with ChatGPT. The Codex CLI and IDE extension support both sign-in methods.
11 11
12Your sign-in method also determines which admin controls and data-handling policies apply.
13
14- With sign in with ChatGPT, Codex usage follows your ChatGPT workspace permissions, RBAC, and ChatGPT Enterprise retention and residency settings
15- With an API key, usage follows your API organization's retention and data-sharing settings instead
16
17For the CLI, Sign in with ChatGPT is the default authentication path when no valid session is available.
18
12### Sign in with ChatGPT19### Sign in with ChatGPT
13 20
14When you sign in with ChatGPT from the Codex app, CLI, or IDE Extension, Codex opens a browser window for you to complete the login flow. After you sign in, the browser returns an access token to the CLI or IDE extension.21When you sign in with ChatGPT from the Codex app, CLI, or IDE Extension, Codex opens a browser window for you to complete the login flow. After you sign in, the browser returns an access token to the CLI or IDE extension.
19 26
20OpenAI bills API key usage through your OpenAI Platform account at standard API rates. See the [API pricing page](https://openai.com/api/pricing/).27OpenAI bills API key usage through your OpenAI Platform account at standard API rates. See the [API pricing page](https://openai.com/api/pricing/).
21 28
29Features that rely on ChatGPT credits, such as [fast mode](https://developers.openai.com/codex/speed), are
30available only when you sign in with ChatGPT. If you sign in with an API key,
31Codex uses standard API pricing instead.
32
33Recommendation is to use API key authentication for programmatic Codex CLI workflows (for example CI/CD jobs). Don't expose Codex execution in untrusted or public environments.
34
22## Secure your Codex cloud account35## Secure your Codex cloud account
23 36
24Codex cloud interacts directly with your codebase, so it needs stronger security than many other ChatGPT features. Enable multi-factor authentication (MFA).37Codex cloud interacts directly with your codebase, so it needs stronger security than many other ChatGPT features. Enable multi-factor authentication (MFA).
43 56
44Codex caches login details locally in a plaintext file at `~/.codex/auth.json` or in your OS-specific credential store.57Codex caches login details locally in a plaintext file at `~/.codex/auth.json` or in your OS-specific credential store.
45 58
59For sign in with ChatGPT sessions, Codex refreshes tokens automatically during use before they expire, so active sessions usually continue without requiring another browser login.
60
46## Credential storage61## Credential storage
47 62
48Use `cli_auth_credentials_store` to control where the Codex CLI stores cached credentials:63Use `cli_auth_credentials_store` to control where the Codex CLI stores cached credentials:
74 89
75If the active credentials don't match the configured restrictions, Codex logs the user out and exits.90If the active credentials don't match the configured restrictions, Codex logs the user out and exits.
76 91
7792These settings are commonly applied via managed configuration rather than per-user setup. See [Managed configuration](https://developers.openai.com/codex/security#managed-configuration).These settings are commonly applied via managed configuration rather than per-user setup. See [Managed configuration](https://developers.openai.com/codex/enterprise/managed-configuration).
93
94## Login diagnostics
95
96Direct `codex login` runs write a dedicated `codex-login.log` file under
97your configured log directory. Use it when you need to debug browser-login or
98device-code failures, or when support asks for login-specific logs.
99
100## Custom CA bundles
101
102If your network uses a corporate TLS proxy or private root CA, set
103`CODEX_CA_CERTIFICATE` to a PEM bundle before logging in. When
104`CODEX_CA_CERTIFICATE` is unset, Codex falls back to `SSL_CERT_FILE`. The same
105custom CA settings apply to login, normal HTTPS requests, and secure websocket
106connections.
107
108```shell
109export CODEX_CA_CERTIFICATE=/path/to/corporate-root-ca.pem
110codex login
111```
78 112
79## Login on headless devices113## Login on headless devices
80 114
130docker cp ~/.codex/auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"164docker cp ~/.codex/auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"
131```165```
132 166
167For a more advanced version of this same pattern on trusted CI/CD runners, see
168[Maintain Codex account auth in CI/CD (advanced)](https://developers.openai.com/codex/auth/ci-cd-auth).
169That guide explains how to let Codex refresh `auth.json` during normal runs and
170then keep the updated file for the next job. API keys are still the recommended
171default for automation.
172
133### Fallback: Forward the localhost callback over SSH173### Fallback: Forward the localhost callback over SSH
134 174
135If you can forward ports between your local machine and the remote host, you can use the standard browser-based flow by tunneling Codex's local callback server (default `localhost:1455`).175If you can forward ports between your local machine and the remote host, you can use the standard browser-based flow by tunneling Codex's local callback server (default `localhost:1455`).