auth

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupCurrentToken

func LookupCurrentToken() (string, error)

LookupCurrentToken retrieves the token for the current base URL.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) BaseURL

func (c *Client) BaseURL() string

func (*Client) PollDeviceAuth

func (c *Client) PollDeviceAuth(ctx context.Context, deviceCode string) (*DeviceAuthPoll, error)

func (*Client) StartDeviceAuth

func (c *Client) StartDeviceAuth(ctx context.Context) (*DeviceAuthStart, error)

type DeviceAuthPoll

type DeviceAuthPoll struct {
	AccessToken string `json:"access_token,omitempty"`
	TokenType   string `json:"token_type,omitempty"`
	ExpiresIn   int    `json:"expires_in,omitempty"`
	Scope       string `json:"scope,omitempty"`
	Error       string `json:"error,omitempty"`
}

type DeviceAuthStart

type DeviceAuthStart struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store manages CLI authentication tokens via a pluggable backend. The production binary always resolves to the OS keyring. A file-backed backend is available only in builds tagged `authfilestore` (used by integration tests to avoid the OS keychain).

func NewStore

func NewStore() *Store

NewStore returns a Store backed by the system keyring (or, in `authfilestore` builds, optionally a file-backed test store).

func NewStoreWithService

func NewStoreWithService(service string) *Store

NewStoreWithService returns a Store with a custom keyring service name (for testing). Honors the same backend selection as NewStore so tests that opt into the file-backed test store via env var see consistent behavior across both constructors.

func (*Store) DeleteToken

func (s *Store) DeleteToken(baseURL string) error

DeleteToken removes a stored token for the given base URL. Returns no error if the token does not exist.

func (*Store) GetToken

func (s *Store) GetToken(baseURL string) (string, error)

GetToken retrieves a stored token for the given base URL. Returns an empty string (and no error) if no token is stored.

func (*Store) SaveToken

func (s *Store) SaveToken(baseURL, token string) error

SaveToken persists an access token for the given base URL.

Jump to

Keyboard shortcuts

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