Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CLIKeyName ¶
CLIKeyName scopes the key name to the user and machine that created it, so two people (or two machines) sharing an account don't revoke each other's CLI keys on login. The email domain and FQDN suffix are dropped, and the remainder is truncated as needed, to stay within maxKeyNameLen.
func DeleteCredentials ¶
func DeleteCredentials() error
func OpenBrowser ¶
func SaveCredentials ¶
func SaveCredentials(creds *Credentials) error
Types ¶
type Credentials ¶
type Credentials struct {
APIKey string `json:"api_key"`
Source string `json:"source"`
CreatedAt string `json:"created_at"`
Email string `json:"email,omitempty"`
AccountName string `json:"account_name,omitempty"`
}
func LoadCredentials ¶
func LoadCredentials() (*Credentials, error)
type OAuthConfig ¶
type OAuthConfig struct {
BaseURL string
}
func DefaultOAuthConfig ¶
func DefaultOAuthConfig() OAuthConfig
type OAuthResult ¶
type OAuthResult struct {
APIKey string
AccountName string
// CleanupStaleKeys removes API keys left by earlier CLI logins. It is
// never nil and must be called only after APIKey has been validated and
// persisted, so a failure in between cannot revoke the previous key while
// leaving no usable replacement.
CleanupStaleKeys func()
}
func RunOAuthFlow ¶
func RunOAuthFlow(ctx context.Context, cfg OAuthConfig) (*OAuthResult, error)
type UserInfo ¶
func ValidateAccessToken ¶
func ValidateToken ¶
ValidateToken calls the whoami endpoint with the given bearer token. tokenLabel names the credential in error messages (e.g. "API key", "access token"), since the endpoint accepts both an API key and an OAuth access token.
Click to show internal directories.
Click to hide internal directories.