oauthclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oauthclient implements explicit, local OAuth login for remote MCP. Invocation never opens a browser or replays an upstream operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(resource string, c Config) error

Types

type AuthorizationResult

type AuthorizationResult struct{ Code, State, Iss string }

type Callback

type Callback struct {
	URL string
	// contains filtered or unexported fields
}

func NewCallback

func NewCallback(raw string) (*Callback, error)

NewCallback accepts only literal loopback IPs. Port zero picks an ephemeral port for DCR; pre-registered clients should configure a fixed redirect URL.

func (*Callback) Close

func (r *Callback) Close()

func (*Callback) Fetch

func (r *Callback) Fetch(notify func(string) error) FetchCode

type Config

type Config struct {
	ClientSecretCredential  string   `json:"client_secret_credential,omitempty"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method,omitempty"`
	ClientID                string   `json:"client_id,omitempty"`
	ClientIDMetadataURL     string   `json:"client_id_metadata_url,omitempty"`
	RedirectURL             string   `json:"redirect_url,omitempty"`
	Issuer                  string   `json:"issuer,omitempty"`
	Scopes                  []string `json:"scopes,omitempty"`
}

type Discovery

type Discovery struct {
	TokenEndpointAuthMethods      []string `json:"tokenEndpointAuthMethodsSupported,omitempty"`
	RevocationEndpointAuthMethods []string `json:"revocationEndpointAuthMethodsSupported,omitempty"`
	DeviceAuthorizationEndpoint   string   `json:"deviceAuthorizationEndpoint,omitempty"`
	RevocationEndpoint            string   `json:"revocationEndpoint,omitempty"`
	Resource                      string   `json:"resource"`
	Issuer                        string   `json:"issuer"`
	AuthorizationEndpoint         string   `json:"authorizationEndpoint"`
	TokenEndpoint                 string   `json:"tokenEndpoint"`
	RegistrationEndpoint          string   `json:"registrationEndpoint,omitempty"`
	ClientIDMetadataSupported     bool     `json:"clientIdMetadataSupported"`
	Scopes                        []string `json:"scopesSupported,omitempty"`
	// contains filtered or unexported fields
}

type FetchCode

type FetchCode func(context.Context, string) (*AuthorizationResult, error)

type Manager

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

Manager never caches bearer tokens between HTTP requests: logout and refresh performed by another process are visible on the next request.

func New

func New(resource, profile string, cfg Config, store credentials.Store) (*Manager, error)

func (*Manager) Discover

func (m *Manager) Discover(ctx context.Context) (*Discovery, error)

Discover does unauthenticated GETs only. DCR, browser consent and token exchange are exclusively part of explicit Login.

func (*Manager) Login

func (m *Manager) Login(ctx context.Context, redirect string, fetch FetchCode) error

func (*Manager) LoginDevice

func (m *Manager) LoginDevice(ctx context.Context, show func(verificationURL, userCode string) error) error

LoginDevice is explicit user consent, never a fallback during tool calls. Device flow requires a pre-registered client; it never performs registration.

func (*Manager) Logout

func (m *Manager) Logout(ctx context.Context) error

func (*Manager) RevokeLogout

func (m *Manager) RevokeLogout(ctx context.Context) error

RevokeLogout revokes refresh and access tokens before deleting local state. Any remote failure retains the session so the user can retry or explicitly choose local-only logout; server revocation is never claimed on failure.

func (*Manager) Status

func (m *Manager) Status(ctx context.Context) (Status, error)

func (*Manager) Token

func (m *Manager) Token(ctx context.Context) (string, error)

type Status

type Status struct {
	State       string     `json:"state"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	Refreshable bool       `json:"refreshable"`
	Issuer      string     `json:"issuer,omitempty"`
}

Jump to

Keyboard shortcuts

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