Skip to main content

Codex Token Exchange Failed 403 and Error Sending Request Fixes

token_exchange_failed alone doesn’t say who is at fault. A 403 in the details is a server refusal; error sending request means Codex got no reply.

LaoZhang AI TeamPublishedUpdated 22 min read
On this page
Codex token-exchange 403: read the full error, preserve response details, distinguish an unexplained refusal from a country, account or workspace restriction, and check the actual Codex host

Token exchange failed means Codex could not swap the one-time authorization code from your browser sign-in for its access tokens. Codex reports every such failure on the same browser page, headed Sign-in could not be completed with the error code token_exchange_failed, so neither the heading nor the code tells you whether your account is blocked, OpenAI's sign-in service is in trouble, or your own network is at fault. Read the text after Token exchange failed: before changing anything.

Token exchange failed: token endpoint returned status 403 Forbidden means the code-for-token request received a refusal. If it continues with Country, region, or territory not supported, that is an eligibility refusal, and no proxy, cache or device change will fix it. Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token) means the request never got an answer at all, so the problem sits between the machine running Codex and that endpoint; codex doctor shows the underlying error the page leaves out. A browser that finishes while the terminal keeps waiting needs a callback check. These lead to different recovery steps.

Run codex --version and codex login status in the shell or host that failed, keep the redacted error, then use the matching branch below. A successful status command only confirms that credentials are present; it does not prove they work remotely. The CLI reference makes that distinction.

Match the full error to the next action

Error or symptomWhat it establishesNext action
token endpoint returned status 403 Forbidden, with no further explanationThe exchange request received a refusal; the cause remains unknownPreserve the response details, then check the actual Codex process’s network and login configuration
Country, region, or territory not supported, unsupported_country_region_territory or another explicit country/region denialThe response identifies an access restrictionCheck the current official eligibility information; contact support if it appears wrong. Stop proxy and cache experiments
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)The client could not complete that request; there is no status, and the nested error mattersFind the underlying error with codex doctor, then check the failing host’s outbound route, proxy and certificate trust. Do not treat it as identical to an HTTP 403 response
Browser approval completes, but Codex keeps waiting for the callbackThe browser result has not reached the waiting processUse an enabled device-code flow; otherwise arrange callback access with the remote-host owner
Device-code request returns 403: account/login/start failed: failed to request device code: device code request failed with status 403 Forbidden (code -32603) or Error logging in with device code: device code request failed with status 403 ForbiddenThat device-code request was refusedRead its body and confirm device login is enabled and permitted; switching flows does not override a country or policy denial
Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)The device-code request never got an answer eitherTreat it like the request-sending error above; switching sign-in methods does not change the network path
Login finishes, then a task fails with 401, 403, or a refresh/workspace messageThe failure is after the initial exchangeCheck the active method, workspace and provider route; preserve the new error as a separate failure

The HTTP definition of 403 allows refusal for reasons unrelated to credentials. It also advises against automatically repeating the same request with the same credentials. The number alone does not establish that OpenAI’s origin handled the request: a proxy or another intermediary can return a refusal too.

The same failure is worded differently depending on where you signed in. Only the prefix changes; the part after Token exchange failed: is still what decides the branch.

Where you signed inWhat you see
Browser page from Codex’s own login server (CLI, IDE extension or desktop app)A card titled “Codex login” with the heading Sign-in could not be completed, an Error code row reading token_exchange_failed and a Details row starting Token exchange failed:
Terminal, after codex loginToken exchange error: … followed by Error logging in: Token exchange failed: … (GitHub issue #41434)
Codex desktop appSign-in failed: Login server error: Token exchange failed: … (English form as reported by users in GitHub issue #38482); in other interface languages only the prefix is translated, as in 登录失败:Login server error: … or Войти в систему не удалось: Login server error: …

The translated desktop prefixes come from a search of the app bundle of the Codex desktop app 26.1111.21308 for macOS on November 15, 2026, which found the sign-in failure templates 登录失败:{rawMessage} and Войти в систему не удалось: {rawMessage}, with the raw message left in English. Those are the templates as stored in the app, not screens from a live failed sign-in in each language; the English wording relies on the user reports linked in the table.

A 401 that appears after sign-in has its own causes, covered in Codex 401 Incorrect API Key: Outage, Stale Token, or Your Key?. A workspace routing message at startup belongs to Codex workspace routing discovery failed or timed out: account/read failed during TUI bootstrap.

If the response names a country or region, stop here

The full refusal reads Token exchange failed: token endpoint returned status 403 Forbidden: Country, region, or territory not supported, and the desktop app shows it after Sign-in failed: Login server error:. Everything up to the status is Codex’s wording; Country, region, or territory not supported is the sentence the server returned. The same sentence can also come back after a successful sign-in as Failed to refresh token: 403 Forbidden: Country, region, or territory not supported, and it means the same thing there.

For a ChatGPT sign-in rejection, open the current ChatGPT supported-country information and compare it with your actual situation. Only that list and OpenAI decide whether a particular country or account is currently eligible. If you believe the refusal is mistaken, use OpenAI Support with the exact redacted error, timestamp and request ID, if one was returned.

A paid subscription, a new browser session, device-code login or a different credential store does not resolve an explicit eligibility refusal. Do not use another person’s account or a network workaround to evade it.

What "Sign-in could not be completed" and token_exchange_failed mean

The page headed Sign-in could not be completed comes from Codex itself, not from OpenAI’s website. The CLI, the IDE extension and the desktop app run a small login server on your computer, the browser returns to it after you approve sign-in, and that server renders the result as a card titled “Codex login.” The card has the heading, a message, an Error code row, a Details row and one help line: Return to Codex to retry, switch accounts, or contact your workspace admin if access is restricted. That help line is printed for every failure except a missing Codex entitlement, so it does not mean your workspace restricts you. The Details row repeats the message unless the sign-in provider sent its own description, as the Codex login server source on GitHub shows.

token_exchange_failed is set for every failed code-for-token request, whatever the reason. The code alone therefore cannot tell a refusal from a request that never went out, and the message after Token exchange failed: is the only part that can.

On November 15, 2026, the page was reproduced with Codex CLI 0.166.0 on macOS without signing in to any account: codex app-server was started with an empty CODEX_HOME, asked to begin a ChatGPT sign-in, and its local callback was then given a made-up authorization code. The page came back in about a second with Error code token_exchange_failed, the help line, and this message in both the message and Details rows: Token exchange failed: token endpoint returned status 401 Unauthorized: Could not validate your token. Please try signing in again. (request id: …). No credentials file was written, and the app-server reported the sign-in as failed with Login server error: Token exchange failed: token endpoint returned status 401 Unauthorized: …. A refusal therefore carries three things: the HTTP status, the server’s own sentence and a request id. The 401 is how the endpoint answers a fake code, not the 403 you may be seeing, so it shows the shape of a refusal rather than its cause.

When the request cannot be sent, the page is emptier. In the same test, pointing the sign-in at a port that accepts connections and drops them produced Token exchange failed: error sending request for url (…) with Error code token_exchange_failed and nothing else: no status, no request id, no underlying reason. The dropping server saw two connection attempts for the one sign-in, which matches the single retry described in the request-sending section below. Because the page leaves the reason out, that variant has to be diagnosed with codex doctor or the login log.

Other error codes the Codex sign-in page can show

The same page carries a different code when the failure happens at another step. These codes and messages come from the Codex login server source linked above.

Error codeWhen Codex shows itNext step
token_exchange_failedThe code-for-token request failed, refused or never sent; the message starts Token exchange failed:Use the text after the colon and the branches above
missing_authorization_codeThe browser came back without an authorization code; the message is Missing authorization code. Sign-in could not be completed.Start sign-in again from Codex
workspace_restrictionYou signed in to a workspace other than the one Codex’s configuration forcesSwitch accounts, or see the managed workspace check
persist_failedSign-in completed but credentials could not be saved locally.; Details shows the storage errorCheck the credential store described in Renew stored credentials
redirect_failedSign-in completed but redirecting back to Codex failed.Return to Codex and retry
unknown_errorThe failure arrived without any codeRely on the message and Details rows
Any other code, such as access_deniedPassed through from the sign-in provider; the message reads Sign-in failed: plus the provider’s description or codeRead the provider’s description

One provider answer gets a different page. When access_denied comes with a description containing missing_codex_entitlement, the heading becomes You do not have access to Codex and the message This account is not currently authorized to use Codex in this workspace.; that one is for a workspace administrator to grant. A callback whose state value does not match gets no card at all, just the plain text State mismatch with HTTP 400.

error_code: token_exchange_failed with a request_id is a different page

A page reading Login failed. Please start the sign-in process again. with error_code: token_exchange_failed and a request_id comes from OpenAI’s own sign-in site, not from Codex’s local login server; it has no token endpoint URL in it. Desktop-app users signing in with Google reported it on August 31, 2026, and OpenAI Support staff on the OpenAI community forum wrote that the request appeared “to be failing during the Google sign-in OAuth token exchange,” then in a second forum thread that “This issue should already be fixed.” Nothing on your machine produces this page. Start sign-in again from Codex, and if it repeats, send the request_id to OpenAI Support.

Start in the same environment that failed

For CLI sign-in, record these before a retry:

bash
codex --version
codex login status

Write down whether that process runs on your computer, in WSL, in a container, on an SSH host, or inside an IDE’s remote environment. Browser access on your laptop does not demonstrate outbound access from a remote host. Likewise, variables exported in a new terminal do not establish what an already-running IDE inherited.

Keep the exact error text, timestamp with time zone, client version, authentication method and a short redacted response body. Direct codex login runs write codex-login.log under the configured log directory, according to the authentication guide. Inspect it privately for the first relevant failure, rather than publishing the entire file.

Remove authorization codes, device codes, tokens, cookies, full callback URLs, API keys, proxy passwords and unrelated private paths from anything you share. If the body is an HTML block page with a company or proxy identifier, preserve that identifier without the secrets.

You can also check the live OpenAI status page. An incident may change when to retry; the absence of a listed incident does not determine the cause of your individual refusal.

Why Codex says "error sending request for url" and what fixed it

Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token) means Codex never received an HTTP answer from OpenAI’s token endpoint. Something between the Codex process and that endpoint stopped the request, and in the cases users resolved it was a proxy setting, security software, a certificate override or DNS on the machine running Codex. No OpenAI maintainer has stated a root cause or fix in the GitHub issues about this message; the one maintainer comment, closing GitHub issue #5283 on January 13, 2026, suggests device authentication for local firewall or network problems. Device-code sign-in is usually no way around it (see the device-code question at the end), so the fixes below are the ones reporters say worked for them.

Find the underlying error before changing settings

Run these in the same shell, container or remote host that failed, in this order, because each one is cheaper than the next and the first often names the cause outright.

  1. Run codex doctor. Since CLI 0.149.0 it diagnoses endpoint protection and network or proxy failures, according to the Codex 0.149.0 release notes. Lines reporters found there include proxy env vars present, Connection refused, invalid peer certificate: UnknownIssuer and HTTP CONNECT failed with status 407.
  2. Open codex-login.log and look for a line like oauth token exchange transport failure is_timeout=false is_connect=true is_request=true error=error sending request for url (https://auth.openai.com/oauth/token), followed by login callback token exchange failed, as quoted in GitHub issue #41434. A line reading oauth token connection failed; retrying with system proxy means the automatic retry described below already ran and also failed.
  3. Check whether the endpoint answers from that shell at all:
bash
curl -i -X POST https://auth.openai.com/oauth/token

On November 15, 2026, from a Mac with a direct route, this returned HTTP 400 with the JSON message Missing required parameter: 'grant_type'. in under a second, and curl -I on the same URL returned 405. Either status means the endpoint was reached and answered. Through a proxy address where nothing listened, curl exited with code 7 and no HTTP status at all. A 400 still does not prove Codex can reach the endpoint, because curl uses the operating system’s certificate store and its own proxy rules; several reporters below had curl working while Codex failed.

Causes other users confirmed, and how to check each

These are community reports from October 2025 to November 2026 across the CLI, the IDE extension and the desktop app. Each fix is confirmed only by the people who reported it, not by OpenAI.

CauseHow to confirm itFix reported to workReports
Proxy variables pointing at a local port where nothing listens any more, including an old entry in ~/.codex/.env, a shell profile, or upper- and lower-case variables set to different portscodex doctor shows proxy env vars present and Connection refused; the presence check below lists which variables are setCorrect or remove the variables, then quit and restart every Codex process; at least five reporters confirmed itissue #26764, issue #13811, issue #41434
Codex not using the system proxy the browser uses, on a network where a proxy is the only routeThe browser works through the proxy while Codex fails; codex doctor shows a system proxy together with respect system proxy: disabledProxy variables in ~/.codex/.env, launching the app from a shell that has them, Windows user-level variables, or enabling respect_system_proxy; which one worked differed between machinesissue #26764, issue #50994, issue #53261, issue #55826
Security software blocking the new codex.exe that each desktop update installs in a new folderThe failure started right after a desktop update; the security product lists the new codex.exe as restricted or blockedAllow network access for that executable (Kaspersky, TinyWall, a firewall tool); merely pausing Kaspersky did not helpissue #48441, issue #50022, OpenAI forum thread on “Sign-in could not be completed”
A leftover SSL_CERT_FILE or CODEX_CA_CERTIFICATE pointing at an old or unrelated bundle, for example one set by Condacodex doctor shows invalid peer certificate: UnknownIssuer, and one of those variables is setRemove the variableissue #40839, issue #49845
HTTPS scanning by antivirus (Norton, Avast), or a proxy certificate the operating system trusts but Codex does notcurl works on the same machine while Codex reports a certificate errorAdd an exception for Codex in the antivirus, or point SSL_CERT_FILE at an exported system bundleissue #36490, issue #41434
DNS that other tools tolerate: Cloudflare WARP’s local resolver, a stale IPv6 resolver left in /etc/resolv.conf, broken DNS inside WSL, or a proxy given by a hostname without a usable IPv6 recordThe failure goes away when WARP is disconnected or the resolver is corrected; inside WSL, curl -v https://auth.openai.com cannot resolve the nameCorrect that resolver, or give the proxy by its IPv4 addressissue #51405, issue #41847, issue #13811, issue #45426
Windows desktop app set to run Codex inside WSL, where DNS returns only IPv6runCodexInWindowsSubsystemForLinux = true in the desktop settings; inside WSL, auth.openai.com resolves only to IPv6 addressesTurn that setting offissue #44990
A Dev Container image without ca-certificatescurl works in the container while the IDE extension failsInstall ca-certificates in the image before the extension is installedissue #24633

Two popular explanations did not hold up in those threads. The Cloudflare-challenge theory rests on a curl -I request to the site root, which can get a challenge; a POST to /oauth/token, the request Codex actually makes, returns ordinary JSON, as shown in issue #44990 and in the curl check above. Signing in through the CLI or the IDE extension first and then opening the desktop app worked for several reporters, but in issue #49845 the desktop app started its own sign-in and failed again, so it is a workaround to try rather than a fix.

Does a dead proxy variable still break sign-in on 0.156.0 and later?

Not on its own, as long as another route works. Since Codex CLI 0.156.0, released September 22, 2026, a code-for-token request that fails to connect is retried once through the system proxy, and that fallback is on by default. The retry happens only for connection failures before any redirect, connection setup is limited to ten seconds, and a response timeout is never retried because the one-time code may already be used, according to the Codex 0.156.0 release notes and pull request #46562.

On November 15, 2026, with CLI 0.166.0 on a Mac that had a working direct route to auth.openai.com and no system proxy configured, pointing HTTPS_PROXY, HTTP_PROXY and ALL_PROXY (upper and lower case) at a local port where nothing listened did not break the exchange: the request still reached the token endpoint in 0.7 seconds. A proxy port that accepted the connection and then closed it gave the same result in 0.6 seconds. That is one Mac, so it says nothing about Windows or the desktop app, which has no public release notes showing which builds include the fallback. The reports that confirmed the dead-variable fix in the table above were all posted before 0.156.0 shipped.

The fallback does not help when a proxy is the only way out of your network and neither your variables nor your system proxy settings point at a working one. On such a network, the opt-in respect_system_proxy feature, added for Windows and macOS in 0.142.1 and 0.142.2, lets Codex’s authentication follow the system proxy, PAC and WPAD settings; it can be switched on from /experimental in 0.167.0 and is still off by default there (0.142.2 release notes, 0.167.0 release notes). If codex doctor shows HTTP CONNECT failed with status 407 on Windows, the 0.164.0 release added answering proxy authentication with the signed-in user’s Negotiate or NTLM credentials, so update first.

Browser approved, but token exchange failed

Codex authentication stages from browser authorization and callback to token exchange, credential storage, and a signed-in request

Browser approval, callback delivery, token exchange, credential storage and a working task are separate milestones. A browser success message confirms only its part of the flow. The exact token-endpoint 403 points to the subsequent exchange attempt, so forwarding a callback port alone may leave it unchanged.

First check the network used by the Codex process. If your organization requires an outbound proxy, use its approved address and protocol. If its block page names a denied authentication destination, give the network owner that hostname and the redacted block identifier. Changing the model API Base URL is a different operation and does not establish a repair to the sign-in endpoint.

Do not rely on the blanket advice that Codex always ignores system proxies. The current official changelog records system-proxy fallback for login and startup requests. That fallback retries only connections that failed to open, so it cannot change a 403 that a server actually returned; its conditions and a test on 0.166.0 are in the request-sending section above. Check your installed client and actual launcher instead of assuming another user’s setup applies.

Check proxy presence without printing proxy credentials

For a POSIX shell, the following reports only whether each variable is set. It deliberately does not print values; “set” can include an empty value.

bash
for name in HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXY https_proxy http_proxy all_proxy no_proxy; do
  if printenv "$name" >/dev/null 2>&1; then
    printf '%s: set\n' "$name"
  else
    printf '%s: unset\n' "$name"
  fi
done

Run it in the shell from which you will launch Codex. It checks that shell, not a separate GUI process, system proxy settings or whether any proxy works. On Windows without a POSIX shell, inspect the approved environment settings for the launcher privately; do not paste an environment dump into a ticket.

If the launcher has missing or incorrect proxy settings, correct it to use the approved proxy’s actual address and protocol. Check those values privately with the network owner; there is no universal proxy port or scheme to copy. In a container or remote host, the proxy must be reachable from that environment, not merely from your laptop.

Keep the callback’s local traffic separate from outbound authentication traffic. Preserve any required NO_PROXY exclusions; do not add all OpenAI domains to that variable, because your network may require those requests to use its proxy. If the affected application needs to inherit changed settings, restart it through its approved launcher. Then retry from the same environment:

bash
codex login

Compare the new error with the saved one. If the same proxy block remains, send its identifier and the token endpoint hostname to the network owner. If the reply now explicitly names country or workspace policy, stop network edits and use that branch instead.

The presence-only snippet above received offline syntax and fixture checks. The checks run on November 15, 2026 did not sign in to a real account; they exercised the failure page and the proxy fallback with Codex CLI 0.166.0 on macOS, as described in the sections above. The recovery commands here follow OpenAI’s documentation and were not run against a live sign-in.

Use a corporate CA only for a certificate-trust failure

If the nested error identifies an untrusted certificate chain and your company uses TLS inspection, obtain its approved PEM bundle. In the same POSIX shell:

bash
export CODEX_CA_CERTIFICATE="/path/to/approved-company-ca.pem"
codex login

The custom CA documentation says Codex uses CODEX_CA_CERTIFICATE, falling back to SSL_CERT_FILE when it is unset. This applies to login, HTTPS and secure WebSocket connections. Keep certificate verification enabled. An ordinary HTTP 403 response is not evidence that a new CA bundle is needed.

Remote login: repair callback reachability

If the browser completes authorization and the remote terminal still waits, the callback may be going to your laptop while its listener is on the remote host. OpenAI documents device-code login and SSH forwarding for this situation in headless authentication.

Device-code login is the preferred documented option, currently labeled beta. Enable it in your personal ChatGPT security settings, or have the workspace administrator permit it. Then run on the machine where Codex will work:

bash
codex login --device-auth

Open the link the command prints on your own browser, sign in and enter the one-time code from that terminal. Do not share the code or enter one supplied by someone else. If the device request itself returns 403, return to its response details; this route removes the need for the browser to reach Codex’s callback listener. It still needs outbound connectivity and an eligible account. Keep the full response text of a device-code 403 when you ask for help, since the error line itself does not state a reason; Codex Headless Login: Device Code, SSH Tunnel, or auth.json covers setting up device-code sign-in itself.

If device login is unavailable, the remote-host owner can arrange permitted callback reachability for the normal browser flow. OpenAI documents SSH forwarding as one option in the headless guide above. That addresses a terminal still waiting for a browser callback; it does not repair an exchange request that already returned 403. Do not expose the callback listener to the public internet.

OpenAI also documents transferring your own file-based login cache to a trusted headless machine. That fallback applies only when a successful login produced an actual auth.json file, both machines are under your control, and the transfer is permitted. A keyring-only or ephemeral session has no such file to copy. With custom CODEX_HOME, use its real location rather than assuming ~/.codex. Follow the official transfer instructions linked above; do not copy another person’s credentials or treat a copied cache as permission to access a forbidden workspace.

Renew stored credentials only when that is the problem

Codex recovery choices for a waiting callback, a request-sending error, a saved-account or refresh problem, and explicit access restrictions, followed by same-host login and request checks

A credential reset is useful when the intended route is allowed but the saved account is wrong, or a later refresh error asks you to sign in again. It is not the first response to an unexplained exchange 403.

For ordinary stored authentication, the documented reset is:

bash
codex logout
codex login
codex login status

Be prepared to sign in again in the IDE too: the CLI and IDE extension share cached login details. If the process selects workload identity from its environment, Codex rejects login and logout; have the owner of that identity configuration check it instead. These behaviors are described in the authentication guide.

Do not delete the entire ~/.codex directory. Credential storage is configurable, and that directory can hold configuration, logs and other state. The documented storage modes are:

ModeWhere credentials liveWhy deleting the default file may miss the problem
fileauth.json under CODEX_HOME, normally ~/.codexA custom home changes the path
keyringOS credential storeThe file is not the active store
autoOS store when available, otherwise fileThe active store depends on availability
ephemeralCurrent process memoryThere is no persistent login file

Automatic refresh normally handles ChatGPT session renewal during use. When it fails, preserve the exact refresh error before replacing credentials; a refresh failure after login is a different stage from the initial code exchange.

Managed workspace rejection needs an administrator check

If the error names a workspace restriction, ask the administrator to confirm your membership, permitted login methods and allowed workspace. Current local authentication requirements can enforce allowed_login_methods, allowed_chatgpt_workspaces, cli_auth_credentials_store and chatgpt_base_url before credentials load.

A user’s forced_login_method and forced_chatgpt_workspace_id must comply with those requirements. No matching workspace makes ChatGPT login unavailable; API authentication remains an option only if permitted. A cached session or user configuration override cannot remove the administrator’s restriction. Stop changing local proxy or credential settings once an explicit policy denial identifies the controlling boundary.

Would API-key login solve your task?

For an allowed local workflow, an API key can provide a different authentication route. With a key already supplied securely through OPENAI_API_KEY, the official command is:

bash
printenv OPENAI_API_KEY | codex login --with-api-key
codex login status

Do not put the key itself in the command line or print it separately. API usage is billed through OpenAI Platform at API rates, rather than included ChatGPT plan usage. Some workspace or cloud features are limited or unavailable, and Codex cloud requires ChatGPT sign-in. Those boundaries come from OpenAI’s authentication documentation; the API key versus subscription guide explains the billing decision.

A permitted enterprise automation flow may instead use a Codex access token. If the environment already supplies it securely, the documented command is:

bash
printenv CODEX_ACCESS_TOKEN | codex login --with-access-token

This requires the enterprise access-token permission described in the official guide. It is not an ordinary Platform API key.

Switching routes can let you complete an appropriate task, but it does not prove the original ChatGPT exchange works. For a custom model provider, check whether its configuration intentionally uses OpenAI authentication or its own env_key; custom-provider setup covers that separate configuration task. Neither a model gateway nor a Base URL change is a universal login-403 fix.

Verify the recovery on the original host and route

After the corrective action, check three results in order:

  1. The login flow finishes without the original exchange error, or the previously saved session remains available without needing a new login.
  2. codex login status reports the intended authentication method in the same host, container or remote environment. Exit code 0 means credentials are present, as the CLI reference states.
  3. When you are ready to authorize normal usage, start Codex in that same environment and ask for a tiny non-sensitive reply, such as Reply with ROUTE_OK only. Do not read files or run commands. A returned answer demonstrates a working request on that route; it may consume plan usage or incur API charges.

If the small task fails with a different error, retain that new error and investigate its stage. A task working on your laptop does not validate a remote host. API-key success does not validate ChatGPT sign-in. A text reply does not establish every tool, streaming feature or workspace capability your real job needs.

If the same refusal persists after one change supported by the evidence, escalate with the exact redacted error, timestamp, client version, execution environment, intended method, callback result and request ID. Route an explicit network block to the network owner, a workspace policy denial to the administrator, and an unexplained or mistaken account refusal to OpenAI Support. Avoid repeated identical attempts that add no diagnostic information.

Questions about the token-exchange 403

Why does the browser say sign-in succeeded while Codex fails?

The browser authorization and Codex’s token request are separate steps. If Codex prints the token-endpoint 403, inspect that request’s response. If the terminal is simply still waiting, check callback reachability instead. Neither browser result proves a working Codex session.

Does codex login status prove the 403 is fixed?

No. Exit code 0 means credentials are present, according to the CLI reference. Confirm the intended method and, when you authorize usage, a small task on the same host and route. Old cached credentials can make status succeed while a new login fails.

Can device-code login fix a 403 Forbidden?

It can help when the browser cannot reach Codex’s callback listener. It must first be enabled for the account or workspace, and it still needs a working outbound route. It does not override an explicit country, account or policy refusal. See the documented headless login conditions. It is not a fix for error sending request for url either: in at least ten 2026 reports on GitHub and the OpenAI forum, such as GitHub issue #40839, device-code sign-in failed the same way with Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode), because that request leaves from the same machine and network.

Should I clear auth.json or change my proxy first?

Choose from the error details. A saved-session or refresh problem can justify the documented logout/login reset. A request-sending or proxy block error calls for checking the failing process’s route. An explicit access restriction calls for official eligibility or administrator support. Deleting a file may do nothing when credentials are in a keyring, memory or a custom CODEX_HOME. In the GitHub threads about error sending request for url, deleting ~/.codex or auth.json fixed it for two reporters and did nothing for at least six, as in GitHub issue #36490.

Sources30

External pages this guide links to, in the order they appear. Last updated Nov 15, 2026.

  1. 1.CLI referencelearn.chatgpt.com/docs/developer-commands
  2. 2.HTTP definition of 403rfc-editor.org/rfc/rfc9110.html
  3. 3.GitHub issue #41434github.com/openai/codex/issues/41434
  4. 4.GitHub issue #38482github.com/openai/codex/issues/38482
  5. 5.ChatGPT supported-country informationhelp.openai.com/en/articles/7947663-chatgpt-supported-countries
  6. 6.OpenAI Supporthelp.openai.com
  7. 7.Codex login server source on GitHubgithub.com/openai/codex/blob/main/codex-rs/login/src/server.rs
  8. 8.OpenAI community forumcommunity.openai.com/t/authentication-error-when-trying-to-login-using-the-desktop-app/1393787
  9. 9.second forum threadcommunity.openai.com/t/i-cant-login-for-some-reason-and-only-get-this-error-message/1393865
  10. 10.authentication guidelearn.chatgpt.com/docs/auth
  11. 11.live OpenAI status pagestatus.openai.com
  12. 12.GitHub issue #5283github.com/openai/codex/issues/5283
  13. 13.Codex 0.149.0 release notesgithub.com/openai/codex/releases/tag/rust-v0.149.0
  14. 14.issue #26764github.com/openai/codex/issues/26764
  15. 15.issue #13811github.com/openai/codex/issues/13811
  16. 16.issue #50994github.com/openai/codex/issues/50994
  17. 17.issue #53261github.com/openai/codex/issues/53261
  18. 18.issue #55826github.com/openai/codex/issues/55826
  19. 19.issue #48441github.com/openai/codex/issues/48441
  20. 20.issue #50022github.com/openai/codex/issues/50022
  21. 21.OpenAI forum thread on “Sign-in could not be completed”community.openai.com/t/codex-login-sign-in-could-not-be-completed-token-exchange-failed/1376953
  22. 22.issue #40839github.com/openai/codex/issues/40839
  23. 23.issue #49845github.com/openai/codex/issues/49845
  24. 24.issue #36490github.com/openai/codex/issues/36490
  25. 25.issue #51405github.com/openai/codex/issues/51405
  26. 26.issue #41847github.com/openai/codex/issues/41847
  27. 27.issue #45426github.com/openai/codex/issues/45426
  28. 28.issue #44990github.com/openai/codex/issues/44990
  29. 29.issue #24633github.com/openai/codex/issues/24633
  30. 30.Codex 0.156.0 release notesgithub.com/openai/codex/releases/tag/rust-v0.156.0