claude

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package claude provides token refresh functionality for Anthropic credentials used by the scheduler.

Package claude provides authentication functionality for Anthropic's Claude API. This file implements a custom HTTP transport using utls to bypass TLS fingerprinting.

Index

Constants

View Source
const (
	TokenURL = "https://api.anthropic.com/v1/oauth/token"
	ClientID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e"
)

Variables

This section is empty.

Functions

func NewAnthropicHttpClient

func NewAnthropicHttpClient(cfg *config.SDKConfig) *http.Client

NewAnthropicHttpClient creates an HTTP client that bypasses TLS fingerprinting for Anthropic domains by using utls with Chrome fingerprint. It accepts optional SDK configuration for proxy settings.

Types

type ClaudeAuth

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

func NewClaudeAuth

func NewClaudeAuth(cfg *config.Config) *ClaudeAuth

NewClaudeAuth creates a new claude auth.

func NewClaudeAuthWithProxyURL

func NewClaudeAuthWithProxyURL(cfg *config.Config, proxyURL string) *ClaudeAuth

NewClaudeAuthWithProxyURL creates a new refresh client instance. proxyURL takes precedence over cfg.ProxyURL when non-empty.

func (*ClaudeAuth) RefreshTokens

func (o *ClaudeAuth) RefreshTokens(ctx context.Context, refreshToken string) (*ClaudeTokenData, error)

RefreshTokens refreshes access token via refresh token.

func (*ClaudeAuth) RefreshTokensWithRetry

func (o *ClaudeAuth) RefreshTokensWithRetry(ctx context.Context, refreshToken string, maxRetries int) (*ClaudeTokenData, error)

RefreshTokensWithRetry refreshes refresh tokens with retry.

type ClaudeTokenData

type ClaudeTokenData struct {
	// AccessToken is the OAuth2 access token for API access
	AccessToken string `json:"access_token"`
	// RefreshToken is used to obtain new access tokens
	RefreshToken string `json:"refresh_token"`
	// Email is the Anthropic account email
	Email string `json:"email"`
	// Expire is the timestamp of the token expire
	Expire string `json:"expired"`
}

ClaudeTokenData holds OAuth token information from Anthropic

Jump to

Keyboard shortcuts

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