Documentation
¶
Index ¶
- func GeneratePKCE() (verifier, challenge string, err error)
- func GetAnthropicAPIKey(flagValue string) (string, string, error)
- func OpenBrowser(url string) error
- func TryOpenBrowser(url string)
- type AnthropicCredentials
- type AuthData
- type CredentialManager
- func (cm *CredentialManager) GetAnthropicCredentials() (*AnthropicCredentials, error)
- func (cm *CredentialManager) GetCredentialsPath() string
- func (cm *CredentialManager) GetValidAccessToken() (string, error)
- func (cm *CredentialManager) HasAnthropicCredentials() (bool, error)
- func (cm *CredentialManager) LoadCredentials() (*CredentialStore, error)
- func (cm *CredentialManager) RemoveAnthropicCredentials() error
- func (cm *CredentialManager) SaveCredentials(store *CredentialStore) error
- func (cm *CredentialManager) SetAnthropicCredentials(apiKey string) error
- func (cm *CredentialManager) SetOAuthCredentials(creds *AnthropicCredentials) error
- type CredentialStore
- type OAuthClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePKCE ¶
GeneratePKCE generates PKCE verifier and challenge for OAuth flow
func GetAnthropicAPIKey ¶
GetAnthropicAPIKey is a convenience function that checks stored credentials first, then falls back to environment variables and flags
func OpenBrowser ¶
OpenBrowser opens the default browser to the specified URL
func TryOpenBrowser ¶
func TryOpenBrowser(url string)
TryOpenBrowser attempts to open the browser but doesn't fail if it can't
Types ¶
type AnthropicCredentials ¶
type AnthropicCredentials struct { Type string `json:"type"` // "oauth" or "api_key" APIKey string `json:"api_key,omitempty"` // For API key auth AccessToken string `json:"access_token,omitempty"` // For OAuth RefreshToken string `json:"refresh_token,omitempty"` // For OAuth ExpiresAt int64 `json:"expires_at,omitempty"` // For OAuth CreatedAt time.Time `json:"created_at"` }
AnthropicCredentials holds Anthropic API credentials
func (*AnthropicCredentials) IsExpired ¶
func (c *AnthropicCredentials) IsExpired() bool
IsExpired checks if the OAuth token is expired
func (*AnthropicCredentials) NeedsRefresh ¶
func (c *AnthropicCredentials) NeedsRefresh() bool
NeedsRefresh checks if the OAuth token needs refresh (5 minutes before expiry)
type CredentialManager ¶
type CredentialManager struct {
// contains filtered or unexported fields
}
CredentialManager handles credential storage and retrieval
func NewCredentialManager ¶
func NewCredentialManager() (*CredentialManager, error)
NewCredentialManager creates a new credential manager
func (*CredentialManager) GetAnthropicCredentials ¶
func (cm *CredentialManager) GetAnthropicCredentials() (*AnthropicCredentials, error)
GetAnthropicCredentials retrieves Anthropic API credentials
func (*CredentialManager) GetCredentialsPath ¶
func (cm *CredentialManager) GetCredentialsPath() string
GetCredentialsPath returns the path to the credentials file
func (*CredentialManager) GetValidAccessToken ¶
func (cm *CredentialManager) GetValidAccessToken() (string, error)
GetValidAccessToken returns a valid access token, refreshing if necessary
func (*CredentialManager) HasAnthropicCredentials ¶
func (cm *CredentialManager) HasAnthropicCredentials() (bool, error)
HasAnthropicCredentials checks if Anthropic credentials are stored
func (*CredentialManager) LoadCredentials ¶
func (cm *CredentialManager) LoadCredentials() (*CredentialStore, error)
LoadCredentials loads credentials from the file
func (*CredentialManager) RemoveAnthropicCredentials ¶
func (cm *CredentialManager) RemoveAnthropicCredentials() error
RemoveAnthropicCredentials removes stored Anthropic credentials
func (*CredentialManager) SaveCredentials ¶
func (cm *CredentialManager) SaveCredentials(store *CredentialStore) error
SaveCredentials saves credentials to the file
func (*CredentialManager) SetAnthropicCredentials ¶
func (cm *CredentialManager) SetAnthropicCredentials(apiKey string) error
SetAnthropicCredentials stores Anthropic API credentials (for API key auth)
func (*CredentialManager) SetOAuthCredentials ¶
func (cm *CredentialManager) SetOAuthCredentials(creds *AnthropicCredentials) error
SetOAuthCredentials stores OAuth credentials
type CredentialStore ¶
type CredentialStore struct {
Anthropic *AnthropicCredentials `json:"anthropic,omitempty"`
}
CredentialStore holds all stored credentials
type OAuthClient ¶
type OAuthClient struct { ClientID string AuthorizeURL string TokenURL string RedirectURI string Scopes string }
OAuthClient handles OAuth authentication with Anthropic
func NewOAuthClient ¶
func NewOAuthClient() *OAuthClient
NewOAuthClient creates a new OAuth client with Anthropic configuration
func (*OAuthClient) ExchangeCode ¶
func (c *OAuthClient) ExchangeCode(code, verifier string) (*AnthropicCredentials, error)
ExchangeCode exchanges an authorization code for tokens
func (*OAuthClient) GetAuthorizationURL ¶
func (c *OAuthClient) GetAuthorizationURL() (*AuthData, error)
GetAuthorizationURL generates the authorization URL with PKCE parameters
func (*OAuthClient) RefreshToken ¶
func (c *OAuthClient) RefreshToken(refreshToken string) (*AnthropicCredentials, error)
RefreshToken refreshes an access token using a refresh token