auth

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package auth loads (and, when necessary, refreshes) the OAuth credentials that Claude Code and Codex already store on disk / in the Keychain. We reuse the official tools' credentials rather than managing our own login.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaudeAuth

type ClaudeAuth struct {
	// contains filtered or unexported fields
}

ClaudeAuth provides a current Claude access token, reloading from the store (Keychain on macOS, ~/.claude/.credentials.json elsewhere) and refreshing via the refresh token when needed.

func NewClaudeAuth

func NewClaudeAuth() *ClaudeAuth

NewClaudeAuth returns an empty holder; the token is loaded lazily.

func (*ClaudeAuth) Refresh

func (a *ClaudeAuth) Refresh(ctx context.Context) (string, error)

Refresh exchanges the refresh token for a new access token and writes the rotated credentials back to the store so the official CLI stays in sync.

func (*ClaudeAuth) Reload

func (a *ClaudeAuth) Reload(ctx context.Context) (string, error)

Reload forces a re-read from the store (e.g. the official CLI may have refreshed the token since we last read it) and returns the fresh token.

func (*ClaudeAuth) Token

func (a *ClaudeAuth) Token(ctx context.Context) (string, error)

Token returns a cached access token, loading from the store on first use.

type CodexAuth

type CodexAuth struct {
	// contains filtered or unexported fields
}

CodexAuth loads and refreshes the Codex OAuth tokens stored in ~/.codex/auth.json (or $CODEX_HOME/auth.json).

func NewCodexAuth

func NewCodexAuth() *CodexAuth

func (*CodexAuth) AccountID

func (a *CodexAuth) AccountID(ctx context.Context) (string, error)

AccountID returns the ChatGPT account id, sent as the chatgpt-account-id header on usage requests.

func (*CodexAuth) Refresh

func (a *CodexAuth) Refresh(ctx context.Context) (string, error)

Refresh exchanges the refresh token for a new access token and writes the rotated tokens back to auth.json so the Codex CLI stays in sync.

func (*CodexAuth) Reload

func (a *CodexAuth) Reload(ctx context.Context) (string, error)

Reload forces a re-read from auth.json (the Codex CLI may have refreshed it).

func (*CodexAuth) Token

func (a *CodexAuth) Token(ctx context.Context) (string, error)

Token returns a cached access token, loading from auth.json on first use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL