auth

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyFilePath

func APIKeyFilePath() (string, error)

APIKeyFilePath returns the path to the local API key file.

func ClearAPIKey

func ClearAPIKey() error

ClearAPIKey removes the local API key.

func ClearTokens

func ClearTokens() error

ClearTokens removes the token file from disk.

func ConfigDirPath

func ConfigDirPath() (string, error)

ConfigDirPath returns the path to the local sitectl config directory.

func LoadAPIKey

func LoadAPIKey() (string, error)

LoadAPIKey loads the local API key.

func SaveAPIKey

func SaveAPIKey(apiKey string) (string, error)

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

func TokenFilePath() (string, error)

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.

Jump to

Keyboard shortcuts

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