Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( DefaultClientID = "n3XETVLxuMMtXJg37Q" DefaultClientSecret = "uYuRebCD6XJegxfuPfTuAvah7hGQB7en" )
Default OAuth consumer credentials embedded in the CLI binary. These are not secret — they identify the app, not the user. The security is in the user's browser-based authorization flow. This is the same pattern used by GitHub CLI (gh). Override with BB_CLIENT_ID / BB_CLIENT_SECRET env vars or --client-id / --client-secret flags.
Functions ¶
func AuthorizeURL ¶
AuthorizeURL builds the OAuth authorization URL.
Types ¶
type Credentials ¶
type Credentials struct {
Username string `json:"username"`
APIToken string `json:"api_token,omitempty"`
// OAuth fields
AuthMethod string `json:"auth_method,omitempty"` // "api_token" or "oauth"
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt int64 `json:"expires_at,omitempty"`
ClientID string `json:"client_id,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
}
Credentials holds the authentication credentials.
func (*Credentials) IsOAuth ¶
func (c *Credentials) IsOAuth() bool
IsOAuth returns true if the credentials use OAuth authentication.
type FileStore ¶
type FileStore struct{}
FileStore implements Store using a JSON file on disk.
func NewFileStore ¶
func NewFileStore() *FileStore
NewFileStore creates a new file-based credential store.
func (*FileStore) DeleteCredentials ¶
DeleteCredentials removes the credentials file.
func (*FileStore) GetCredentials ¶
func (f *FileStore) GetCredentials() (*Credentials, error)
GetCredentials reads credentials from the credentials file.
func (*FileStore) SetCredentials ¶
func (f *FileStore) SetCredentials(creds *Credentials) error
SetCredentials writes credentials to the credentials file with 0600 permissions.
type Store ¶
type Store interface {
GetCredentials() (*Credentials, error)
SetCredentials(creds *Credentials) error
DeleteCredentials() error
}
Store is the interface for credential storage.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
TokenType string `json:"token_type"`
Scopes string `json:"scopes"`
}
TokenResponse holds the response from the OAuth token endpoint.
func ExchangeCode ¶
func ExchangeCode(clientID, clientSecret, code string, port int) (*TokenResponse, error)
ExchangeCode exchanges an authorization code for tokens.
func RefreshAccessToken ¶
func RefreshAccessToken(clientID, clientSecret, refreshToken string) (*TokenResponse, error)
RefreshAccessToken refreshes an expired access token.