oauth_error

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category int

Category is a coarse, UX-oriented classification of an OAuth error, used to decide how to handle it (which problem page to show, whether a retry helps).

const (
	// CategoryFailed is the default: an unexpected failure or one that indicates
	// application misconfiguration. Retrying is not expected to help.
	CategoryFailed Category = iota
	// CategoryCancelled is a user-initiated, recoverable outcome (declined consent
	// or pressed cancel/back). The user can simply try again.
	CategoryCancelled
	// CategoryAccessDenied is an authorization denial: the user authenticated but
	// is not permitted (tenant/role/admin policy). Retrying re-denies.
	CategoryAccessDenied
	// CategoryUnavailable is a transient provider failure; trying again later may
	// succeed.
	CategoryUnavailable
)

type Error

type Error struct {
	// Code is the OAuth 2.0 `error` parameter, e.g. "access_denied".
	Code string
	// Subcode is a provider extension (Microsoft `error_subcode`, e.g. "cancel").
	Subcode string
	// Description is the human-readable `error_description` parameter.
	Description string
	// Uri is the `error_uri` parameter.
	Uri string
}

Error represents an OAuth 2.0 authorization error response (RFC 6749 §4.1.2.1), which the provider returns via the redirect URI instead of an authorization code, e.g. when the user declines consent or cancels (error=access_denied).

func New

func New(code, subcode, description, uri string) *Error

func (*Error) Category

func (e *Error) Category() Category

Category classifies the error for UX handling. The mapping is intentionally conservative: a bare access_denied is treated as a cancellation (the common, non-alarming case), and only escalated to a denial when an explicit policy signal is present. Unrecognized errors fall through to CategoryFailed so they are never silently treated as recoverable.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetCode

func (e *Error) GetCode() string

GetCode satisfies github.com/Motmedel/utils_go/pkg/errors.CodeErrorI so the OAuth error code is emitted as ECS `error.code` by the error context extractor.

Jump to

Keyboard shortcuts

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