Skip to content
BENIBIX Learn

claude setup-token Command

Also known as claude setup-token, CLAUDE_CODE_OAUTH_TOKEN, Long-lived OAuth token

It makes a sign-in token for CI and scripts. It lasts one year.

Think of it like

It is like a pass for the bus that lasts a year.

Example

Lucy wants her GitHub job to run Claude Code on her plan. She runs claude setup-token and copies the token. Then she saves it as a secret with the name CLAUDE_CODE_OAUTH_TOKEN.

Why it matters

A job that runs at night cannot click a sign-in page. A token lets it sign in on its own.

Definition

claude setup-token makes a sign-in token that lasts one year, for CI jobs and scripts that have no browser. You approve it once in the browser, and the token prints in your terminal. It is not saved anywhere, so copy it and set it as CLAUDE_CODE_OAUTH_TOKEN where the job runs. It needs a Claude plan.

Example code

bash
claude setup-token
Print a one-year token for a CI job.
The token is the middle path, from your terminal to the CI job.

Common mistake

Pasting the token into a file in the repository. Anyone who reads it can use your plan. Keep it in a secret store.

Key takeaways

  1. 1
    Lasts one year. Then make a new one.
  2. 2
    Printed once. Not saved.
  3. 3
    Set the variable. CLAUDE_CODE_OAUTH_TOKEN.

Compare

Learn it properly