Help us shape the future of Go! Take the 2026 Go Developer Survey

oauth

package
v0.19.13 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopilotAvailableModelIDs

func CopilotAvailableModelIDs(credential *auth.Credential) ([]string, bool)

func GeneratePKCE

func GeneratePKCE(random io.Reader) (verifier, challenge string, err error)

func GitHubCopilotBaseURL

func GitHubCopilotBaseURL(token, enterpriseDomain string) string

func OAuthErrorHTML

func OAuthErrorHTML(message, details string) string

func OAuthSuccessHTML

func OAuthSuccessHTML(message string) string

OAuthSuccessHTML retains the upstream HTML helper contract; browser callbacks use the Orb presentation above.

func OpenAICodexAccountID

func OpenAICodexAccountID(token string) string

Types

type Anthropic

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

func NewAnthropic

func NewAnthropic(options *AnthropicOptions) *Anthropic

func (*Anthropic) Login

func (flow *Anthropic) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*Anthropic) Name

func (*Anthropic) Name() string

func (*Anthropic) Refresh

func (flow *Anthropic) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*Anthropic) ToAuth

func (*Anthropic) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type AnthropicOptions

type AnthropicOptions struct {
	AuthorizeURL string
	TokenURL     string
	CallbackHost string
	CallbackPort int
	RedirectURI  string
	HTTPClient   *http.Client
	Random       io.Reader
	Now          func() time.Time
	Listen       func(network, address string) (net.Listener, error)
}

type DeviceIDSource added in v0.14.0

type DeviceIDSource interface {
	DeviceID() (string, error)
}

DeviceIDSource is implemented by login interactions that can supply a stable installation ID (a UUID); Sign in with ChatGPT sends it to OpenAI as the agent host ID.

type GitHubCopilot

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

func NewGitHubCopilot

func NewGitHubCopilot(options *GitHubCopilotOptions) *GitHubCopilot

func (*GitHubCopilot) Login

func (flow *GitHubCopilot) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*GitHubCopilot) Name

func (*GitHubCopilot) Name() string

func (*GitHubCopilot) Refresh

func (flow *GitHubCopilot) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*GitHubCopilot) ToAuth

func (*GitHubCopilot) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type GitHubCopilotOptions

type GitHubCopilotOptions struct {
	DeviceCodeURL   string
	AccessTokenURL  string
	CopilotTokenURL string
	CopilotBaseURL  string
	HTTPClient      *http.Client
	KnownModelIDs   []string
	Sleep           func(context.Context, time.Duration) error
}

type KimiCoding

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

func NewKimiCoding

func NewKimiCoding(options *KimiCodingOptions) *KimiCoding

func (*KimiCoding) Login

func (flow *KimiCoding) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*KimiCoding) LoginLabel

func (*KimiCoding) LoginLabel() string

func (*KimiCoding) Name

func (*KimiCoding) Name() string

func (*KimiCoding) Refresh

func (flow *KimiCoding) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*KimiCoding) ToAuth

func (*KimiCoding) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type KimiCodingOptions

type KimiCodingOptions struct {
	OAuthHost  string
	HTTPClient *http.Client
	Now        func() time.Time
	Sleep      func(context.Context, time.Duration) error
}

type Loopback added in v0.14.0

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

Loopback waits for one sign-in redirect.

func ListenLoopback added in v0.14.0

func ListenLoopback(options LoopbackOptions) (*Loopback, error)

func (*Loopback) Cancel added in v0.14.0

func (loopback *Loopback) Cancel() bool

Cancel stops waiting unless a callback is being completed, and reports whether it did.

func (*Loopback) Close added in v0.14.0

func (loopback *Loopback) Close()

func (*Loopback) RedirectURI added in v0.14.0

func (loopback *Loopback) RedirectURI() string

func (*Loopback) Wait added in v0.14.0

func (loopback *Loopback) Wait(ctx context.Context) error

Wait returns when the browser completed sign-in, with Complete's error.

type LoopbackOptions added in v0.14.0

type LoopbackOptions struct {
	// Provider names what is signed in to on the browser page.
	Provider string
	// Host is the address to listen on; RedirectHost the host in the redirect
	// URI when it differs.
	Host, RedirectHost, Path string
	// Port 0 picks a free port.
	Port  int
	State string
	// Complete finishes sign-in with the callback's query before the browser
	// page is sent, so the page shows failures.
	Complete func(url.Values) error
}

LoopbackOptions configure a loopback redirect for sign-ins outside the provider registry, such as MCP servers'.

type Meta added in v0.14.0

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

func NewMeta added in v0.14.0

func NewMeta(options *MetaOptions) *Meta

func (*Meta) Login added in v0.14.0

func (flow *Meta) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*Meta) LoginLabel added in v0.14.0

func (*Meta) LoginLabel() string

func (*Meta) Name added in v0.14.0

func (*Meta) Name() string

func (*Meta) Refresh added in v0.14.0

func (flow *Meta) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*Meta) ToAuth added in v0.14.0

func (*Meta) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type MetaOptions added in v0.14.0

type MetaOptions struct {
	DeviceAuthorizationURL string
	DeviceTokenURL         string
	APIKeyMintURL          string
	HTTPClient             *http.Client
	Now                    func() time.Time
	Sleep                  func(context.Context, time.Duration) error
}

type OpenAIChatGPT added in v0.14.0

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

func NewOpenAIChatGPT added in v0.14.0

func NewOpenAIChatGPT(options *OpenAIChatGPTOptions) *OpenAIChatGPT

func (*OpenAIChatGPT) Login added in v0.14.0

func (flow *OpenAIChatGPT) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*OpenAIChatGPT) LoginLabel added in v0.14.0

func (*OpenAIChatGPT) LoginLabel() string

func (*OpenAIChatGPT) Name added in v0.14.0

func (*OpenAIChatGPT) Name() string

func (*OpenAIChatGPT) Refresh added in v0.14.0

func (flow *OpenAIChatGPT) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*OpenAIChatGPT) ToAuth added in v0.14.0

func (*OpenAIChatGPT) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type OpenAIChatGPTOptions added in v0.14.0

type OpenAIChatGPTOptions struct {
	AuthorizeURL string
	TokenURL     string
	CallbackHost string
	CallbackPort int
	HTTPClient   *http.Client
	Random       io.Reader
	Now          func() time.Time
	Listen       func(network, address string) (net.Listener, error)
}

type OpenAICodex

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

func NewOpenAICodex

func NewOpenAICodex(options *OpenAICodexOptions) *OpenAICodex

func (*OpenAICodex) Login

func (flow *OpenAICodex) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*OpenAICodex) Name

func (*OpenAICodex) Name() string

func (*OpenAICodex) Refresh

func (flow *OpenAICodex) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*OpenAICodex) ToAuth

func (*OpenAICodex) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type OpenAICodexOptions

type OpenAICodexOptions struct {
	AuthorizeURL          string
	TokenURL              string
	DeviceUserCodeURL     string
	DeviceTokenURL        string
	DeviceVerificationURI string
	RedirectURI           string
	DeviceRedirectURI     string
	CallbackHost          string
	CallbackPort          int
	HTTPClient            *http.Client
	Random                io.Reader
	Now                   func() time.Time
	Listen                func(network, address string) (net.Listener, error)
}

type OpenRouter

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

func NewOpenRouter

func NewOpenRouter(options *OpenRouterOptions) *OpenRouter

func (*OpenRouter) Login

func (flow *OpenRouter) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*OpenRouter) LoginLabel

func (*OpenRouter) LoginLabel() string

func (*OpenRouter) Name

func (*OpenRouter) Name() string

func (*OpenRouter) Refresh

func (*OpenRouter) Refresh(_ context.Context, credential *auth.Credential) (*auth.Credential, error)

Refresh is a no-op: the OAuth flow mints a permanent API key.

func (*OpenRouter) ToAuth

func (*OpenRouter) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type OpenRouterOptions

type OpenRouterOptions struct {
	AuthorizeURL string
	TokenURL     string
	CallbackHost string
	LoginTimeout time.Duration
	HTTPClient   *http.Client
	Random       io.Reader
	Listen       func(network, address string) (net.Listener, error)
}

type XAI

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

func NewXAI

func NewXAI(options *XAIOptions) *XAI

func (*XAI) Login

func (flow *XAI) Login(ctx context.Context, interaction auth.AuthInteraction) (*auth.Credential, error)

func (*XAI) LoginLabel

func (*XAI) LoginLabel() string

func (*XAI) Name

func (*XAI) Name() string

func (*XAI) Refresh

func (flow *XAI) Refresh(ctx context.Context, credential *auth.Credential) (*auth.Credential, error)

func (*XAI) ToAuth

func (*XAI) ToAuth(credential *auth.Credential) (auth.ModelAuth, error)

type XAIOptions

type XAIOptions struct {
	DeviceCodeURL string
	TokenURL      string
	HTTPClient    *http.Client
	Now           func() time.Time
	Sleep         func(context.Context, time.Duration) error
}

Jump to

Keyboard shortcuts

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