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.
Usage Examples
Basic token fetch
scorpiox-claudecode-fetchtoken
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkw...
Verbose diagnostics
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
export CLAUDE_TOKEN=$(scorpiox-claudecode-fetchtoken)
curl -H "Authorization: Bearer $CLAUDE_TOKEN" https://api.anthropic.com/v1/messages
CI/CD pipeline integration
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
ssh build-server "scorpiox-claudecode-fetchtoken"
scorpiox-claudecode-fetchtoken || scorpiox-claudecode-refreshtoken && scorpiox-claudecode-fetchtoken