auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthorizeURL

func BuildAuthorizeURL(apiKey, callbackURL string) string

BuildAuthorizeURL builds the Trello authorization URL for interactive login.

func FormatDeviceUserCode added in v1.1.0

func FormatDeviceUserCode(code string) string

FormatDeviceUserCode inserts a dash: WDJBMJHT → WDJB-MJHT.

func NewTokenCaptureServerForTest

func NewTokenCaptureServerForTest() (*tokenCaptureServer, error)

NewTokenCaptureServerForTest exposes callback-server creation for tests.

func RequireAuth

func RequireAuth(store credentials.Store, profile string) (credentials.Credentials, error)

RequireAuth loads credentials for the given profile. Returns AUTH_REQUIRED if missing.

Types

type BrowserOpener

type BrowserOpener func(string) error

BrowserOpener opens the Trello authorize URL in a browser.

type ClearResult

type ClearResult struct {
	Configured bool    `json:"configured"`
	AuthMode   *string `json:"authMode"` // Always null after clear
}

ClearResult is the response shape for auth clear.

func Clear

func Clear(store credentials.Store, profile string) (ClearResult, error)

Clear removes stored credentials for the given profile.

type DeviceClient added in v1.1.0

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

DeviceClient communicates with the pairing service.

func NewDeviceClient added in v1.1.0

func NewDeviceClient(baseURL string) *DeviceClient

NewDeviceClient creates a client for the pairing service.

func (*DeviceClient) PollToken added in v1.1.0

func (c *DeviceClient) PollToken(deviceCode string) (*DeviceTokenResponse, error)

PollToken makes a single poll request for the token.

func (*DeviceClient) RequestCode added in v1.1.0

func (c *DeviceClient) RequestCode() (*DeviceCodeResponse, error)

RequestCode initiates a device authorization flow.

type DeviceCodeResponse added in v1.1.0

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

DeviceCodeResponse from the pairing service.

type DeviceTokenResponse added in v1.1.0

type DeviceTokenResponse struct {
	AccessToken string `json:"access_token"`
	APIKey      string `json:"api_key"`
}

DeviceTokenResponse from the pairing service on successful exchange.

type LoginResult

type LoginResult struct {
	Configured bool    `json:"configured"`
	AuthMode   *string `json:"authMode"`
	Member     *Member `json:"member"`
}

LoginResult is the response shape for auth login.

func CompleteLogin

func CompleteLogin(ctx context.Context, store credentials.Store, profile, apiKey, token, baseURL, authMode string) (LoginResult, error)

CompleteLogin validates a captured token and stores credentials.

func Login

func Login(ctx context.Context, store credentials.Store, profile, baseURL, apiKey string, openBrowser BrowserOpener, stderr io.Writer) (LoginResult, error)

Login performs the interactive browser authorization flow.

func LoginWithDeviceFlow added in v1.1.0

func LoginWithDeviceFlow(ctx context.Context, store credentials.Store, profile, baseURL, pairingServiceURL string, stderr io.Writer) (LoginResult, error)

LoginWithDeviceFlow runs the RFC 8628 device authorization flow.

type Member

type Member struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	FullName string `json:"fullName"`
}

Member represents a Trello member for auth status responses.

type SetKeyResult

type SetKeyResult struct {
	Configured bool   `json:"configured"`
	AuthMode   string `json:"authMode"`
}

SetKeyResult is the response shape for auth set-key.

func SetKey

func SetKey(store credentials.Store, profile, apiKey string) (SetKeyResult, error)

SetKey stores or updates only the API key for the given profile. If a token already exists, it is preserved so the profile remains configured.

type SetResult

type SetResult struct {
	Configured bool        `json:"configured"`
	AuthMode   string      `json:"authMode"`
	Member     interface{} `json:"-"` // Never included — auth set does not validate
}

SetResult is the response shape for auth set.

func Set

func Set(store credentials.Store, profile, apiKey, token string) (SetResult, error)

Set stores credentials without validating them against the Trello API. Validation is deferred to auth status or the first command that requires auth.

type StatusResult

type StatusResult struct {
	Configured bool    `json:"configured"`
	AuthMode   *string `json:"authMode"`
	Member     *Member `json:"member"`
}

StatusResult is the response shape for auth status.

func Status

func Status(ctx context.Context, store credentials.Store, profile, baseURL string) (StatusResult, error)

Status checks the current authentication state.

Jump to

Keyboard shortcuts

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