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
def looks_like_token(token: str) -> boolCheap 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
def validate_token(token: str, timeout: float=5.0) -> strProbe 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
def extract_token(captured: bytes) -> str | NoneScrape 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
def _best_candidate(data: bytes) -> str | NonePick the best token-looking match in data, or None.