Checking the Codex login status confirms valid credentials are available before starting a session or automation run, preventing failures caused by missing authentication.

The codex login status subcommand reports whether a cached login is present and which method is active (ChatGPT or API key). Cached credentials live in the OS credential store or in /~/.codex/auth.json when file-based storage is enabled.

The status check is read-only and does not refresh, repair, or change credentials, so an expired or missing login still requires a separate login action. Running the status check from the same environment that runs Codex sessions avoids mismatches caused by different shells, users, or runners.

Steps to check Codex login status:

  1. Open a terminal session in the environment used to run codex commands.
  2. Run the login status command.
    $ codex login status
    Logged in using ChatGPT
  3. Confirm the output indicates an authenticated state and shows the active method.

    Common results include Logged in using ChatGPT, Logged in using API key, or a Not logged in message when no credentials are available.

  4. Record the exit code for automation checks.
    $ codex login status >/dev/null 2>&1; echo $?
    0

    codex login status exits 0 when credentials are present.

  5. Run a quick prompt to verify the session can authenticate requests.
    $ codex exec -C /home/user/projects/example-repo "Return OK."
    OK