Skip to content
Back to skills

Claude Oauth Auth

BSecurity

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.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 3, 2026
ai-agentsbashdockerapi

Works with

  • claude code
  • cli
  • api

Security analysis

B88/100
  • criticalSends environment variables or credentials to an external URL

Pro shows the line behind each finding and how to fix it

Scanned September 3, 2026

npx -y skills add aberson/skill-mesh --skill claude-oauth-auth --agent claude-code

Installs 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 with every re-scan.

Security grade badge for Claude Oauth Auth
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/aberson-claude-oauth-auth/badge)](https://www.skillsdirectory.com/skills/aberson-claude-oauth-auth)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…