oauth

package
v3.31.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package oauth provides OAuth 2.0 PKCE authentication flow for CLI applications

Index

Constants

View Source
const (
	DefaultHost = "buildkite.com"
	// DefaultScopes are the default OAuth scopes to request
	DefaultScopes = "read_user read_organizations read_pipelines read_builds write_builds read_agents read_artifacts read_clusters read_teams"
)

Variables

View Source
var DefaultClientID = ""

DefaultClientID is the OAuth client ID for the Buildkite CLI This is blank so we can use ldflags

Functions

This section is empty.

Types

type CallbackResult

type CallbackResult struct {
	Code  string
	State string
	Error string
}

CallbackResult holds the result from the OAuth callback

type Config

type Config struct {
	Host        string // e.g., "buildkite.com"
	ClientID    string // OAuth client ID
	OrgSlug     string // Organization slug (used for organization_uuid lookup)
	OrgUUID     string // Organization UUID
	CallbackURL string // e.g., "http://127.0.0.1:8080/callback"
	Scopes      string // Space-separated OAuth scopes
}

Config holds OAuth configuration

type Flow

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

Flow manages an OAuth authentication flow

func NewFlow

func NewFlow(cfg *Config) (*Flow, error)

NewFlow creates a new OAuth flow

func (*Flow) AuthorizationURL

func (f *Flow) AuthorizationURL() string

AuthorizationURL returns the URL to open in the browser

func (*Flow) Close

func (f *Flow) Close() error

Close cleans up the OAuth flow resources

func (*Flow) ExchangeCode

func (f *Flow) ExchangeCode(ctx context.Context, code string) (*TokenResponse, error)

ExchangeCode exchanges the authorization code for an access token

func (*Flow) WaitForCallback

func (f *Flow) WaitForCallback(ctx context.Context) (*CallbackResult, error)

WaitForCallback waits for the OAuth callback and returns the authorization code

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Scope       string `json:"scope"`
	Error       string `json:"error,omitempty"`
	ErrorDesc   string `json:"error_description,omitempty"`
}

TokenResponse holds the token exchange response

Jump to

Keyboard shortcuts

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