# claude setup-token Command

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

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** claude setup-token, CLAUDE_CODE_OAUTH_TOKEN, Long-lived OAuth token

## Think of it like

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

## 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

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.

## Example code

```bash
claude setup-token
```

Print a one-year token for a CI job.

## Why it matters

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

## 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.

## Three principles

- **Lasts one year.** Then make a new one.
- **Printed once.** Not saved.
- **Set the variable.** CLAUDE_CODE_OAUTH_TOKEN.

## Related terms

- [claude auth login Command](https://learn.benibix.com/term/ai/claude-auth-login-command)
- [Claude Code GitHub Actions](https://learn.benibix.com/term/ai/claude-code-github-actions)
- [OAuth 2.0](https://learn.benibix.com/term/development/oauth)

## Told apart from

- [claude setup-token vs claude auth login](https://learn.benibix.com/compare/claude-setup-token-command-vs-claude-auth-login-command): People think claude setup-token signs in the computer you run it on, and it does not. claude auth login signs you in here and keeps the sign-in. claude setup-token opens the browser once, then prints a token that lasts one year. It saves that token nowhere. You copy it into a CI job, or any machine with no browser.

## Taught in

- [Claude Code Login Commands](https://learn.benibix.com/learn/ai-claude-code-commands/claude-code-login-commands): Claude Code Commands, 3/17

![claude auth login signs you in on this computer. claude setup-token prints a one-year token that a CI job uses instead. claude auth status answers 0 or 1.](https://learn.benibix.com/diagrams/cli-auth.svg)

---

Source: https://learn.benibix.com/term/ai/claude-setup-token-command
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
