Description

Fetches Claude Code OAuth tokens from multiple sources including local credential stores, SSH tunnels, HTTP endpoints, and raw TCP connections. Designed for automated CI/CD pipelines and headless environments where interactive browser-based OAuth flows are unavailable.

Flags & Options

Flag Short Description Takes Value
--verbose Enable verbose output with detailed connection and token exchange diagnostics No

Usage Examples

Basic token fetch
# Fetch the current Claude Code OAuth token from local credential store scorpiox-claudecode-fetchtoken eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkw...
Verbose diagnostics
# Show connection details and token exchange steps scorpiox-claudecode-fetchtoken --verbose [info] checking local credential store: ~/.config/claude-code/credentials.json [info] found cached token, checking expiry... [info] token valid for 3412 more seconds [info] returning cached token eyJhbGciOiJSUzI1NiIs...
Pipe to environment variable
# Set token as environment variable for downstream tools export CLAUDE_TOKEN=$(scorpiox-claudecode-fetchtoken) # Use in a curl request to the Claude API curl -H "Authorization: Bearer $CLAUDE_TOKEN" https://api.anthropic.com/v1/messages
CI/CD pipeline integration
# In a CI job — fetch token, verify, then run Claude Code TOKEN=$(scorpiox-claudecode-fetchtoken --verbose 2>/dev/null) if [ -n "$TOKEN" ]; then echo "Token acquired, launching Claude Code session..." scorpiox-claudecode --token "$TOKEN" --task "run tests" else echo "Failed to acquire token" >&2 exit 1 fi
Remote token fetch via SSH
# Fetch token from a remote machine where the user is logged in ssh build-server "scorpiox-claudecode-fetchtoken" # Combine with scorpiox-claudecode-refreshtoken if expired scorpiox-claudecode-fetchtoken || scorpiox-claudecode-refreshtoken && scorpiox-claudecode-fetchtoken

Source & Build Info

Source File
scorpiox/scorpiox-claudecode-fetchtoken.c
Lines of Code
626
Dependencies
libcurl libsxnet libsxutil

Related Tools