claudewheel v0.24.2 /claudewheel.auth
Edit
On this page

Validate OAuth tokens against the Anthropic API and extract them from captured output.

#claudewheel.auth

#claudewheel.auth

Validate OAuth tokens against the Anthropic API and extract them from captured output.

#looks_like_token

python
def looks_like_token(token: str) -> bool

Cheap offline check: does token have the shape of an API token?

Anchors on the sk-ant- prefix with at least one trailing token character. Never makes a network call -- callers use it to reject garbage before spending a round-trip on :func:validate_token.

#validate_token

python
def validate_token(token: str, timeout: float=5.0) -> str

Probe the Anthropic API with the token; return one of the four states.

Never logs, prints, or embeds the token in any raised exception.

#extract_token

python
def extract_token(captured: bytes) -> str | None

Scrape an OAuth token from raw PTY-captured terminal output.

Strips terminal escape sequences, joins lines (to defeat hard-wrapping mid-token), anchors the search after the last "valid for 1 year" label when present (Ink re-renders frames; the last frame wins), and applies a length sanity check. Returns the best candidate or None.

#_best_candidate

python
def _best_candidate(data: bytes) -> str | None

Pick the best token-looking match in data, or None.

Search