Aident AI

Claude Code Login Loops on Authorize? Fix It Safely
If Claude Code opens the browser, you click Authorize, and Claude asks you to sign in again before returning to the same Authorize screen, stop repeating the same browser flow. Keep your local projects and session data intact. Start one fresh login, open its exact authorization URL in a private browser session that is already signed in to the intended Claude account, and use the manual verification-code path when it is offered.
Use this order:
Confirm that this is the Authorize and sign-in loop, not an expired token, API-key override, or service incident.
Record the version, diagnostic result, active authentication method, and clock state.
Reset authentication once with Claude Code's documented logout and login flow.
Move the same fresh authorization URL to a private browser session and complete the manual-code fallback.
Stop after one controlled retry and collect evidence for support if the loop remains.
Do not delete ~/.claude, remove project transcripts, paste an OAuth token into chat, disable browser security, or request a series of email links. Those actions do not repair the browser-to-terminal handoff and can destroy useful evidence.
Match the Exact Failure
This guide applies to the following sequence:
Use a different diagnosis when Claude Code reports OAuth token has expired, Invalid code, organization disabled, or a provider-specific credential error. Anthropic's error reference treats those as separate failures. If authentication succeeds but the wrong account or plan is active, check /status and the account selected in the browser before changing local files.
The active July 2026 issue uses the wording “state parameter dropped after sign in again,” but Anthropic has not confirmed that root cause in the thread. Treat the title as a report, not a verified protocol diagnosis.
Prerequisites
Close or finish any Claude Code work that cannot be interrupted. Keep one terminal for the recovery attempt and close extra Claude Code sessions so several processes do not compete to refresh the same saved login.
Record the non-secret state:
Inside Claude Code, run:
On Windows PowerShell, list only relevant variable names, not their values:
Expected result: you know the Claude Code version, whether diagnostics report a credential-store problem, which authentication method /status sees, and whether an API credential could be overriding a subscription login. Do not print or share the variable values.
Also check Anthropic's service status. If authentication is an active incident, preserve the evidence and wait instead of cycling through login links.
Step 1: Run One Clean Documented Reset
Inside Claude Code, run:
Exit Claude Code completely, open a new terminal, and start the dedicated login command:
Anthropic documents /logout followed by a new login as the normal reset. It also documents claude auth login for terminals where the interactive paste field or automatic browser return is unreliable.
Expected result: Claude Code prints or opens one new authorization URL and waits for that login attempt. Keep this URL paired with this terminal. Do not reuse a URL or code from an earlier attempt.
If the clean flow succeeds, reopen Claude Code and verify /status. Stop there. A successful fresh attempt is evidence that the failure was intermittent, not proof of a particular root cause.
Step 2: Isolate the Browser Session
If the fresh attempt loops, close the browser window that handled it. Open a private or incognito window in a current browser and sign in directly at claude.ai with the account you want Claude Code to use.
Run claude auth login again to create a new attempt. Copy its exact URL into that private window. At an interactive login prompt, Claude Code also lets you press c to copy the OAuth URL instead of relying on automatic browser launch.
Expected result: the new attempt uses one clean cookie context and one known Claude account. If it completes, run /status and confirm the subscription or organization shown is the intended one.
This is a containment test. Reports in the active issue found different results across Safari, Firefox, Chrome, private windows, and a phone. That variation suggests browser or session state is involved, but it does not prove the provider-side cause.
Step 3: Use the Manual Verification-Code Path
If the page offers Enter verification code, use it for this fresh attempt:
Keep
claude auth loginwaiting in the terminal.Open the exact new authorization URL in the private browser session.
Choose the verification-code option when the page presents it.
Complete the email verification. The email link may open a page that displays a long code.
Paste only that displayed code into the waiting terminal.
Anthropic officially documents the browser-code fallback for WSL, SSH, containers, native Windows, and terminals where the redirect or paste handoff fails. The community issue shows that the same path can also bypass this Authorize loop.
Expected result: the terminal accepts the code, reports a successful login, and /status shows the intended Claude account. A code is single-use and belongs to one authorization URL. If it expires or is rejected, discard that pair and make one new attempt instead of mixing links and codes.
Why this can work: it replaces the automatic browser callback with an explicit code handoff to the waiting CLI. It narrows the failure boundary without exposing the saved OAuth token or modifying session files.
Step 4: Separate Repeated Logout From the Authorize Loop
If login succeeds but Claude Code asks again after restart, check the documented persistence causes:
Make sure the system clock and time zone synchronize automatically. Token validation depends on accurate time.
Update Claude Code if you are on a version older than the fixes described in the current troubleshooting documentation.
On macOS, run
claude doctorand check whether the login Keychain is locked or out of sync.Close parallel sessions before another login attempt. They share saved credentials and coordinate token renewal.
Recheck the non-secret environment-variable names and
/status. AnANTHROPIC_API_KEYcan take precedence over/login.
For a general installation or update warning, follow Claude Code Auto-Update Failed? Diagnose Before Reinstalling. If you intentionally use more than one account, keep their browser and credential contexts explicit with How to Use Work and Personal Claude Code Accounts Safely.
Expected result: either the saved login survives a restart, or you have isolated the failure to clock, Keychain, account selection, environment override, or provider-side authentication.
Step 5: Stop Retrying and Escalate With Evidence
Stop after one clean reset and one manual-code attempt if the loop remains. Collect:
Claude Code version and installation method
Operating system and terminal or IDE
Browser and whether the session was private
The exact page sequence, without the authorization URL or code
claude doctorresult with secrets removed/statusauthentication method and account typeWhether the system clock is synchronized
Approximate UTC time of the attempt
Use /feedback when Claude Code can start, or contact Anthropic support for an account-level loop. Link the active issue if its sequence matches. Never attach the authorization URL, email link, verification code, Keychain item, token, or environment-variable value.
Common Failure Modes
Failure | Safer response |
|---|---|
Clicking Authorize repeatedly | Create one new attempt in one clean browser context |
Mixing an old URL with a new terminal | Keep each URL and code paired with its waiting process |
Requesting many magic links | Stop after one controlled retry to avoid expiry and throttling |
Deleting | Preserve settings and transcripts; use |
Pasting a saved OAuth token into chat | Use the official login flow and credential store |
Login succeeds but the wrong plan appears | Check |
Private mode still loops | Try the documented manual-code handoff, then escalate |
Re-login returns after every restart | Check time, Keychain, parallel sessions, and credential precedence |
Why This Fix Works
The Claude account session in the browser, the one-time authorization request, the redirect or manual-code handoff, and Claude Code's saved credential are separate boundaries. Repeating Authorize inside one stale browser context tests none of them independently.
A fresh private session controls the browser state. A newly generated URL controls the authorization attempt. The manual code controls the handoff back to the waiting CLI. /status, the non-secret environment check, clock verification, and claude doctor then test whether the resulting credential is selected and stored correctly.
That structure follows the repeatable lesson from Aident's Ollama networking guide: use the exact failure wording, answer early, change one boundary at a time, state the expected result, and explain why the test narrows the cause. For OAuth failures inside an MCP server rather than Claude's own account login, use How to Fix MCP OAuth Callback Errors in Docker and WSL.
Verify One Read-Only Action Without Sharing a Key
After Claude Code authentication is stable, set up Aident Loadout by pasting:
Then ask:
Expected result: one current catalog record, zero provider executions, and no API key copied into the prompt. This verifies a real authenticated integration boundary without turning a login test into an external write.
Sources
Troubleshoot installation and login, Anthropic Claude Code documentation, accessed August 2, 2026
Claude Code error reference, Anthropic Claude Code documentation, accessed August 2, 2026
Log in to your Claude account, Anthropic Help Center, accessed August 2, 2026
How do I log out of all active sessions?, Anthropic Help Center, accessed August 2, 2026
Claude account
/loginOAuth loop, issue opened July 16, 2026Claude Code logs me out constantly, community report accessed August 2, 2026
Claude Code login expired, community report accessed August 2, 2026
Refresh this guide when Anthropic closes issue 77966, changes the documented manual-code flow, or updates credential persistence behavior.


