auth

package
v6.9.0-aug.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides authentication functionality for various AI service providers. It includes interfaces and implementations for token storage and authentication methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefreshWithRetry

func RefreshWithRetry[T any](
	ctx context.Context,
	refreshToken string,
	maxRetries int,
	refreshFn func(ctx context.Context, refreshToken string) (T, error),
	isNonRetryable func(error) bool,
) (T, error)

RefreshWithRetry retries the given refresh function up to maxRetries times with linear backoff. If isNonRetryable is non-nil, it is called on each error to decide whether to stop early.

func SaveTokenJSON

func SaveTokenJSON(authFilePath string, storage any, metadata map[string]any) error

SaveTokenJSON persists a token storage struct to disk in JSON format. It creates the necessary directory structure, merges metadata into the top-level JSON object, and writes the result atomically.

Types

type TokenStorage

type TokenStorage interface {
	// SaveTokenToFile persists authentication tokens to the specified file path.
	//
	// Parameters:
	//   - authFilePath: The file path where the authentication tokens should be saved
	//
	// Returns:
	//   - error: An error if the save operation fails, nil otherwise
	SaveTokenToFile(authFilePath string) error
}

TokenStorage defines the interface for storing authentication tokens. Implementations of this interface should provide methods to persist authentication tokens to a file system location.

Directories

Path Synopsis
Package antigravity provides OAuth2 authentication functionality for the Antigravity provider.
Package antigravity provides OAuth2 authentication functionality for the Antigravity provider.
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
Package codex provides authentication and token management for OpenAI's Codex API.
Package codex provides authentication and token management for OpenAI's Codex API.
Package empty provides a no-operation token storage implementation.
Package empty provides a no-operation token storage implementation.
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
Package kimi provides authentication and token management for Kimi (Moonshot AI) API.
Package kimi provides authentication and token management for Kimi (Moonshot AI) API.
Package oauthcommon provides shared OAuth server, error types, and HTML templates used by the Claude (Anthropic) and Codex (OpenAI) authentication flows.
Package oauthcommon provides shared OAuth server, error types, and HTML templates used by the Claude (Anthropic) and Codex (OpenAI) authentication flows.
Package qwen provides authentication and token management functionality for Alibaba's Qwen AI services.
Package qwen provides authentication and token management functionality for Alibaba's Qwen AI services.
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.

Jump to

Keyboard shortcuts

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