workos_errors

package
v6.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailVerificationRequiredCode                 = "email_verification_required"
	MFAEnrollmentCode                             = "mfa_enrollment"
	MFAChallengeCode                              = "mfa_challenge"
	OrganizationSelectionRequiredCode             = "organization_selection_required"
	SSORequiredCode                               = "sso_required"
	OrganizationAuthenticationMethodsRequiredCode = "organization_authentication_methods_required"
)

Authentication error code constants

Variables

This section is empty.

Functions

func IsBadRequest

func IsBadRequest(err error) bool

func TryGetHTTPError

func TryGetHTTPError(r *http.Response) error

TryGetHTTPError returns an error when the http response contains invalid status code.

Types

type AuthenticationFactor

type AuthenticationFactor struct {
	ID   string     `json:"id"`
	Type FactorType `json:"type"`
}

AuthenticationFactor represents an MFA factor

type EmailVerificationRequiredError

type EmailVerificationRequiredError struct {
	HTTPError
	Code                       string `json:"code"`
	Message                    string `json:"message"`
	Email                      string `json:"email"`
	EmailVerificationID        string `json:"email_verification_id"`
	PendingAuthenticationToken string `json:"pending_authentication_token"`
}

EmailVerificationRequiredError occurs when a user with unverified email attempts authentication

func (EmailVerificationRequiredError) Error

type ErrorWithMessage

type ErrorWithMessage struct {
	Message string `json:"message"`
}

ErrorWithMessage struct to hold a single error with a message

type FactorType

type FactorType string

FactorType represents the type of Authentication Factor

const (
	SMS  FactorType = "sms"
	TOTP FactorType = "totp"
)

Constants that enumerate the available Types (matching mfa.FactorType)

type FieldError

type FieldError struct {
	Field string
	Code  string
}

type HTTPError

type HTTPError struct {
	Code                       int
	Status                     string
	RequestID                  string
	Message                    string
	ErrorCode                  string
	Errors                     []string
	FieldErrors                []FieldError
	ErrorDescription           string
	RawBody                    string
	PendingAuthenticationToken string
	EmailVerificationID        string
	// Authentication error specific fields
	AuthenticationFactors []AuthenticationFactor                  `json:"authentication_factors,omitempty"`
	Organizations         []PendingAuthenticationOrganizationInfo `json:"organizations,omitempty"`
	ConnectionIDs         []string                                `json:"connection_ids,omitempty"`
	SSOConnectionIDs      []string                                `json:"sso_connection_ids,omitempty"`
	AuthMethods           map[string]bool                         `json:"auth_methods,omitempty"`
	User                  *common.User                            `json:"user,omitempty"`
}

HTTPError represents an http error.

func (HTTPError) Error

func (e HTTPError) Error() string

type MFAChallengeError

type MFAChallengeError struct {
	HTTPError
	Code                       string                 `json:"code"`
	Message                    string                 `json:"message"`
	User                       User                   `json:"user"`
	AuthenticationFactors      []AuthenticationFactor `json:"authentication_factors"`
	PendingAuthenticationToken string                 `json:"pending_authentication_token"`
}

MFAChallengeError occurs when a user needs to complete MFA challenge

func (MFAChallengeError) Error

func (e MFAChallengeError) Error() string

type MFAEnrollmentError

type MFAEnrollmentError struct {
	HTTPError
	Code                       string `json:"code"`
	Message                    string `json:"message"`
	User                       User   `json:"user"`
	PendingAuthenticationToken string `json:"pending_authentication_token"`
}

MFAEnrollmentError occurs when a user needs to enroll in MFA

func (MFAEnrollmentError) Error

func (e MFAEnrollmentError) Error() string

type OrganizationAuthenticationMethodsRequiredError

type OrganizationAuthenticationMethodsRequiredError struct {
	HTTPError
	ErrorCode                  string          `json:"error"`
	ErrorDescription           string          `json:"error_description"`
	Email                      string          `json:"email"`
	SSOConnectionIDs           []string        `json:"sso_connection_ids"`
	AuthMethods                map[string]bool `json:"auth_methods"`
	PendingAuthenticationToken string          `json:"pending_authentication_token"`
}

OrganizationAuthenticationMethodsRequiredError occurs when org restricts auth methods

func (OrganizationAuthenticationMethodsRequiredError) Error

type OrganizationSelectionRequiredError

type OrganizationSelectionRequiredError struct {
	HTTPError
	Code                       string                                  `json:"code"`
	Message                    string                                  `json:"message"`
	User                       User                                    `json:"user"`
	Organizations              []PendingAuthenticationOrganizationInfo `json:"organizations"`
	PendingAuthenticationToken string                                  `json:"pending_authentication_token"`
}

OrganizationSelectionRequiredError occurs when user must choose an organization

func (OrganizationSelectionRequiredError) Error

type PendingAuthenticationOrganizationInfo

type PendingAuthenticationOrganizationInfo struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

PendingAuthenticationOrganizationInfo represents an organization in selection error

type ResponseErrors

type ResponseErrors []string

ResponseErrors is a custom type that can handle unmarshaling []string or []ErrorWithMessage

func (*ResponseErrors) UnmarshalJSON

func (e *ResponseErrors) UnmarshalJSON(data []byte) error

type SSORequiredError

type SSORequiredError struct {
	HTTPError
	ErrorCode                  string   `json:"error"`
	ErrorDescription           string   `json:"error_description"`
	Email                      string   `json:"email"`
	ConnectionIDs              []string `json:"connection_ids"`
	PendingAuthenticationToken string   `json:"pending_authentication_token"`
}

SSORequiredError occurs when user must authenticate via SSO

func (SSORequiredError) Error

func (e SSORequiredError) Error() string

type User

type User = common.User

User is an alias for common.User to maintain consistency

Jump to

Keyboard shortcuts

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