How to authenticate with Claude using a subscription OAuth token instead of an API key. Use when setting up Claude Code sessions, building tools that invoke the claude CLI, or when a user has a Claude subscription but no API key.
Scanned 9/3/2026
Install to Claude Code
npx -y skills add aberson/skill-mesh --skill claude-oauth-auth --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Claude Oauth Auth?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/aberson-claude-oauth-auth)More formats (shields.io, HTML) on the badges page.
---
name: claude-oauth-auth
description: How to authenticate with Claude using a subscription OAuth token instead of an API key. Use when setting up Claude Code sessions, building tools that invoke the claude CLI, or when a user has a Claude subscription but no API key.
user-invokable: false
---
# Claude OAuth Authentication (no API key needed)
**Requirement:** the user must have an active Claude subscription (Pro, Max, or Team) for this method to work. With a subscription, the `claude` CLI supports authentication via `CLAUDE_CODE_OAUTH_TOKEN` instead of `ANTHROPIC_API_KEY` — no API key is required.
## Usage
Set the environment variable and invoke `claude` normally — no API key required:
```bash
CLAUDE_CODE_OAUTH_TOKEN=<token> claude -p "your prompt"
```
In Docker/containers, pass it as an `-e` flag:
```bash
docker run -e CLAUDE_CODE_OAUTH_TOKEN=<token> <image> claude -p "your prompt"
```
In a tmux session, inject via `tmux set-environment` then load with:
```bash
eval "$(tmux show-environment -s)" && claude
```
## Priority
If both `CLAUDE_CODE_OAUTH_TOKEN` and `ANTHROPIC_API_KEY` are present, Claude Code prefers the OAuth token.
## Notes
- The CLI handles token validation and refresh internally — do not manage the OAuth flow yourself.
- Store the token as a file at `~/.config/<yourapp>/.secrets/CLAUDE_CODE_OAUTH_TOKEN` and load it at runtime to avoid hardcoding.
- Never log or expose the token value.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!