Documentation
¶
Overview ¶
Package oauthclient implements explicit, local OAuth login for remote MCP. Invocation never opens a browser or replays an upstream operation.
Index ¶
- func Validate(resource string, c Config) error
- type AuthorizationResult
- type Callback
- type Config
- type Discovery
- type FetchCode
- type Manager
- func (m *Manager) Discover(ctx context.Context) (*Discovery, error)
- func (m *Manager) Login(ctx context.Context, redirect string, fetch FetchCode) error
- func (m *Manager) LoginDevice(ctx context.Context, show func(verificationURL, userCode string) error) error
- func (m *Manager) Logout(ctx context.Context) error
- func (m *Manager) RevokeLogout(ctx context.Context) error
- func (m *Manager) Status(ctx context.Context) (Status, error)
- func (m *Manager) Token(ctx context.Context) (string, error)
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthorizationResult ¶
type AuthorizationResult struct{ Code, State, Iss string }
type Callback ¶
type Callback struct {
URL string
// contains filtered or unexported fields
}
func NewCallback ¶
NewCallback accepts only literal loopback IPs. Port zero picks an ephemeral port for DCR; pre-registered clients should configure a fixed redirect URL.
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 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 (*Manager) Discover ¶
Discover does unauthenticated GETs only. DCR, browser consent and token exchange are exclusively part of explicit Login.
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) RevokeLogout ¶
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.