Documentation
¶
Index ¶
- func APIKeyFilePath() (string, error)
- func ClearAPIKey() error
- func ClearTokens() error
- func ConfigDirPath() (string, error)
- func LoadAPIKey() (string, error)
- func SaveAPIKey(apiKey string) (string, error)
- func SaveTokens(tokens *TokenResponse) error
- func TokenFilePath() (string, error)
- type AuthClient
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyFilePath ¶
APIKeyFilePath returns the path to the local API key file.
func ConfigDirPath ¶
ConfigDirPath returns the path to the local sitectl config directory.
func SaveAPIKey ¶
SaveAPIKey stores the local API key with restricted permissions.
func SaveTokens ¶
func SaveTokens(tokens *TokenResponse) error
SaveTokens saves OAuth tokens to disk with restricted permissions.
func TokenFilePath ¶
TokenFilePath returns the path to the OAuth token file.
Types ¶
type AuthClient ¶
type AuthClient struct {
// contains filtered or unexported fields
}
AuthClient handles unified browser-based authentication.
func NewAuthClient ¶
func NewAuthClient(apiBaseURL string) *AuthClient
NewAuthClient creates a new authentication client.
func (*AuthClient) Login ¶
func (c *AuthClient) Login(ctx context.Context) (*TokenResponse, error)
Login opens the browser to the API's login page and waits for the callback.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token,omitempty"`
IDToken string `json:"id_token"`
TokenType string `json:"token_type"`
ExpiryDate int64 `json:"expiry_date"`
Scope string `json:"scope"`
}
TokenResponse represents the OAuth token response stored locally.
func LoadTokens ¶
func LoadTokens() (*TokenResponse, error)
LoadTokens loads OAuth tokens from disk.
func (*TokenResponse) IsTokenExpired ¶
func (t *TokenResponse) IsTokenExpired() bool
IsTokenExpired checks if the token has expired.