Versions in this module Expand all Collapse all v0 v0.2.0 Aug 14, 2026 Changes in this version + const CallbackIdleTimeout + const CallbackReadHeaderTimeout + const DefaultPollInterval + const MaxCallbackValueLength + const MaxExtraParams + const MaxHeaderBytes + const MaxPollAttempts + const MaxPollInterval + const MaxRequestBodyBytes + const MaxRequestHeaders + const MaxResponseBodyBytes + const MaxResponseHeaders + const MaxScopeLength + const MaxScopes + const MaxStateLength + const MaxTokenLifetime + const MaxTokenValueLength + const MaxVerifierLength + const MinVerifierLength + var ErrCallbackClosed = errors.New("oauth: callback listener closed") + var ErrCallbackOrigin = errors.New("oauth: callback origin rejected") + var ErrCallbackTimeout = errors.New("oauth: callback wait timed out") + var ErrCanceled = credentials.ErrCanceled + var ErrDeviceExpired = errors.New("oauth: device authorization expired") + var ErrInvalidClient = errors.New("oauth: invalid sanctioned client") + var ErrInvalidDefinition = errors.New("oauth: invalid provider definition") + var ErrInvalidEndpoint = errors.New("oauth: invalid endpoint") + var ErrInvalidRequest = errors.New("oauth: invalid request") + var ErrInvalidResponse = errors.New("oauth: invalid provider response") + var ErrInvalidVerifier = errors.New("oauth: invalid PKCE verifier") + var ErrNetwork = errors.New("oauth: provider request failed") + var ErrNilContext = credentials.ErrNilContext + var ErrOriginMismatch = errors.New("oauth: endpoint origin is not pinned") + var ErrPollLimit = errors.New("oauth: device polling limit reached") + var ErrProvider = errors.New("oauth: provider rejected request") + var ErrRedirectRejected = errors.New("oauth: redirect rejected") + var ErrRequestHeadersTooLarge = errors.New("oauth: provider request headers too large") + var ErrRequestTooLarge = errors.New("oauth: provider request too large") + var ErrResponseHeadersTooLarge = errors.New("oauth: provider response headers too large") + var ErrResponseTooLarge = errors.New("oauth: provider response too large") + var ErrRevocationUnsupported = errors.New("oauth: revocation endpoint unavailable") + var ErrStateMismatch = errors.New("oauth: callback state mismatch") + var ErrStateUsed = errors.New("oauth: callback state already used") + var ErrUnsupportedGrant = errors.New("oauth: grant is not allowed") + func GenerateState() (string, error) + func GenerateVerifier() (string, error) + func IsProviderError(err error) bool + func NewState() (string, error) + func NewVerifier() (string, error) + func ParseExpiresIn(value string) (int64, error) + func S256(verifier string) (string, error) + func S256Challenge(verifier string) (string, error) + func ValidateState(expected, received string) error + func ValidateVerifier(verifier string) error + type AuthorizationFlow struct + Callback CallbackInstructions + Challenge string + State string + URL string + Verifier string + func BeginAuthorization(ctx context.Context, definition Definition, options ...Option) (*AuthorizationFlow, error) + func BeginAuthorizationCode(ctx context.Context, definition Definition, options ...Option) (*AuthorizationFlow, error) + func (f *AuthorizationFlow) Close() error + func (f *AuthorizationFlow) Exchange(ctx context.Context, result CallbackResult, options ...Option) (TokenResponse, error) + func (f *AuthorizationFlow) Wait(ctx context.Context) (CallbackResult, error) + func (f AuthorizationFlow) Format(state fmt.State, _ rune) + func (f AuthorizationFlow) LogValue() slog.Value + func (f AuthorizationFlow) String() string + type CallbackInstructions struct + Method string + Path string + RedirectURI string + URL string + func (i CallbackInstructions) Format(state fmt.State, _ rune) + func (i CallbackInstructions) GoString() string + func (i CallbackInstructions) LogValue() slog.Value + func (i CallbackInstructions) String() string + type CallbackResult struct + Code string + ErrorCode string + State string + func ParseCallbackQuery(query url.Values, expectedState string) (CallbackResult, error) + func ParseCallbackURL(raw, expectedState string, exactPath ...string) (CallbackResult, error) + func ParseCallbackURLForInstructions(raw, expectedState string, instructions CallbackInstructions) (CallbackResult, error) + func (r CallbackResult) CallbackError() error + func (r CallbackResult) Format(state fmt.State, _ rune) + func (r CallbackResult) GoString() string + func (r CallbackResult) HasError() bool + func (r CallbackResult) LogValue() slog.Value + func (r CallbackResult) String() string + type ClientIdentity = ClientRegistration + type ClientRegistration struct + AllowedGrants []Grant + AllowedOrigins []string + AllowedRedirectURIs []string + ClientID string + Evidence string + ID string + LoopbackRedirect LoopbackRedirectPolicy + RedirectURIs []string + Sanctioned bool + Scopes []string + type Config = Definition + type Definition struct + AllowedEndpointOrigins []string + AllowedGrants []Grant + AllowedOrigins []string + AuthorizationEndpoint string + AuthorizationParams map[string]string + AuthorizationURL string + Client ClientRegistration + ClientID string + DeviceAuthorizationEndpoint string + DeviceAuthorizationURL string + DeviceParams map[string]string + DeviceParser func([]byte) (DeviceAuthorization, error) + DeviceURL string + ExtraParams map[string]string + Grants []Grant + Origins []string + ParseDeviceResponse func([]byte) (DeviceAuthorization, error) + ParseTokenResponse func([]byte) (TokenResponse, error) + Parser ResponseParser + Registration ClientRegistration + RevocationEndpoint string + RevocationURL string + SanctionedClientID string + Scopes []string + TokenEndpoint string + TokenParams map[string]string + TokenParser func([]byte) (TokenResponse, error) + TokenURL string + func (d Definition) BeginAuthorization(ctx context.Context, options ...Option) (*AuthorizationFlow, error) + func (d Definition) ExchangeCode(ctx context.Context, code, verifier, redirectURI string, options ...Option) (TokenResponse, error) + func (d Definition) Format(state fmt.State, _ rune) + func (d Definition) GoString() string + func (d Definition) LogValue() slog.Value + func (d Definition) PollDevice(ctx context.Context, device DeviceAuthorization, options ...Option) (TokenResponse, error) + func (d Definition) RefreshToken(ctx context.Context, refreshToken string, previous TokenResponse, ...) (TokenResponse, error) + func (d Definition) RevokeToken(ctx context.Context, token string, options ...Option) error + func (d Definition) SortOrigins() []string + func (d Definition) StartDeviceAuthorization(ctx context.Context, options ...Option) (DeviceAuthorization, error) + func (d Definition) StartDeviceFlow(ctx context.Context, options ...Option) (*DeviceFlow, error) + func (d Definition) String() string + func (d Definition) Validate() error + type DeviceAuthorization struct + DeviceCode string + ExpiresAt time.Time + ExpiresIn int64 + Interval int + UserCode string + VerificationURI string + VerificationURIComplete string + func DeviceAuthorizationRequest(ctx context.Context, definition Definition, options ...Option) (DeviceAuthorization, error) + func ParseDeviceAuthorizationResponse(body []byte) (DeviceAuthorization, error) + func (d DeviceAuthorization) Format(state fmt.State, _ rune) + func (d DeviceAuthorization) GoString() string + func (d DeviceAuthorization) LogValue() slog.Value + func (d DeviceAuthorization) String() string + func (d DeviceAuthorization) Valid() bool + type DeviceAuthorizationResponse = DeviceAuthorization + type DeviceFlow struct + Definition Definition + Device DeviceAuthorization + func (f *DeviceFlow) Poll(ctx context.Context, options ...Option) (TokenResponse, error) + type Grant string + const GrantAuthorizationCode + const GrantDeviceAuthorization + const GrantDeviceCode + const GrantRefreshToken + type LoopbackListener struct + func ListenLoopback(ctx context.Context, options ...Option) (*LoopbackListener, error) + func NewLoopbackListener(ctx context.Context, options ...Option) (*LoopbackListener, error) + func (l *LoopbackListener) Client() *http.Client + func (l *LoopbackListener) Close() error + func (l *LoopbackListener) Format(state fmt.State, _ rune) + func (l *LoopbackListener) GoString() string + func (l *LoopbackListener) Instructions() CallbackInstructions + func (l *LoopbackListener) LogValue() slog.Value + func (l *LoopbackListener) ParseCallback(raw string) (CallbackResult, error) + func (l *LoopbackListener) ServeHTTP(response http.ResponseWriter, request *http.Request) + func (l *LoopbackListener) State() string + func (l *LoopbackListener) String() string + func (l *LoopbackListener) Wait(ctx context.Context) (CallbackResult, error) + type LoopbackRedirectPolicy struct + AllowDynamicPort bool + Enabled bool + Host string + Method string + PathPrefix string + type Option func(*operationOptions) + func WithHTTPClient(client *http.Client) Option + func WithMaxPolls(attempts int) Option + func WithPollInterval(interval time.Duration) Option + func WithPollSleeper(sleeper func(context.Context, time.Duration) error) Option + type PKCE struct + Challenge string + State string + Verifier string + func NewPKCE() (PKCE, error) + func (p PKCE) Format(state fmt.State, _ rune) + func (p PKCE) GoString() string + func (p PKCE) LogValue() slog.Value + func (p PKCE) String() string + type ProviderDefinition = Definition + type ProviderError struct + func (e *ProviderError) Code() string + func (e *ProviderError) Error() string + func (e *ProviderError) Format(state fmt.State, _ rune) + func (e *ProviderError) GoString() string + func (e *ProviderError) LogValue() slog.Value + func (e *ProviderError) StatusCode() int + func (e *ProviderError) String() string + func (e *ProviderError) Unwrap() error + type ResponseParser interface + ParseDeviceAuthorization func([]byte) (DeviceAuthorization, error) + ParseTokenResponse func([]byte) (TokenResponse, error) + type Revoker interface + RevokeToken func(context.Context, string, ...Option) error + type StateGuard struct + func NewStateGuard(expected string) (*StateGuard, error) + func (g *StateGuard) Consume(received string) error + func (g *StateGuard) State() string + func (g StateGuard) Format(state fmt.State, _ rune) + func (g StateGuard) GoString() string + func (g StateGuard) LogValue() slog.Value + func (g StateGuard) String() string + type Token = TokenResponse + type TokenResponse struct + AccessToken string + ExpiresAt time.Time + ExpiresIn int64 + RefreshToken string + Scope string + TokenType string + func ExchangeAuthorizationCode(ctx context.Context, definition Definition, code, verifier, redirectURI string, ...) (TokenResponse, error) + func ParseTokenResponse(body []byte) (TokenResponse, error) + func Poll(ctx context.Context, definition Definition, device DeviceAuthorization, ...) (TokenResponse, error) + func PollDeviceAuthorization(ctx context.Context, definition Definition, device DeviceAuthorization, ...) (TokenResponse, error) + func RotateRefreshToken(previous, next TokenResponse) TokenResponse + func (t TokenResponse) Format(state fmt.State, _ rune) + func (t TokenResponse) GoString() string + func (t TokenResponse) LogValue() slog.Value + func (t TokenResponse) Rotate(previous TokenResponse) TokenResponse + func (t TokenResponse) String() string + func (t TokenResponse) Valid() bool v0.1.0 Aug 10, 2026