Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AuthBaseURL = func() string { if v := viper.GetString("auth-url"); v != "" { return v } return "https://eu.prod.surfe.com" }
AuthBaseURL returns the base URL for authentication and API calls. Override via config file (auth-url), env var (SURFER_AUTH_URL), or --auth-url flag.
var ClientID = func() string { if v := viper.GetString("client-id"); v != "" { return v } return "hubspot" }
ClientID returns the OAuth client ID. Override via config file (client-id), env var (SURFER_CLIENT_ID), or --client-id flag.
var LoginTimeout = 2 * time.Minute
var OpenBrowserFunc = openBrowserDefault
OpenBrowserFunc can be overridden in tests to prevent opening a real browser.
Functions ¶
func ClearTokens ¶
func ClearTokens() error
func DecodeTokenClaims ¶
DecodeTokenClaims parses the claims from a JWT access token WITHOUT verifying its signature. It is for local display only (e.g. `surfer whoami`) — never use it for authorization decisions. Returns an error for opaque (non-JWT) tokens.
func GetAccessToken ¶
GetAccessToken returns a valid access token, refreshing if expired. Falls back to SURFE_API_KEY env var for server-to-server usage.
func IsLoggedIn ¶
func IsLoggedIn() bool
func SaveTokens ¶
func SaveTokens(store *TokenStore) error
Types ¶
type TokenStore ¶
type TokenStore struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresAt time.Time `json:"expires_at"`
TokenType string `json:"token_type"`
Scope string `json:"scope"`
}
func LoadTokens ¶
func LoadTokens() (*TokenStore, error)
func RefreshTokens ¶
func RefreshTokens(refreshToken string) (*TokenStore, error)
func StartLogin ¶
func StartLogin() (*TokenStore, error)
StartLogin opens the browser for OAuth authorization and waits for the callback. Uses port 0 (OS-assigned) like wrangler/gh/gcloud to avoid port conflicts.