Skip to content

AuthXException#

authx.exceptions.AuthXException #

AuthXException(*args, login_type=None, **kwargs)

Bases: Exception

Base AuthXException Exception.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

The base exception for all AuthX exceptions.

authx.exceptions.BadConfigurationError #

BadConfigurationError(*args, login_type=None, **kwargs)

Bases: AuthXException

Exception raised when AuthX configuration contains wrong parameters.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when AuthX configuration contains wrong parameters.

authx.exceptions.JWTDecodeError #

JWTDecodeError(*args, login_type=None, **kwargs)

Bases: AuthXException

Exception raised when decoding JSON Web Token fails.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when decoding JSON Web Token fails.

authx.exceptions.NoAuthorizationError #

NoAuthorizationError(*args, login_type=None, **kwargs)

Bases: AuthXException

Exception raised when no token can be parsed from request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when no token can be parsed from request.

authx.exceptions.CSRFError #

CSRFError(*args, login_type=None, **kwargs)

Bases: AuthXException

Exception raised when CSRF protection failed.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when CSRF protection failed.

authx.exceptions.TokenError #

TokenError(*args, login_type=None, **kwargs)

Bases: AuthXException

Base Exception for token related errors.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when token is invalid.

authx.exceptions.MissingTokenError #

MissingTokenError(*args, login_type=None, **kwargs)

Bases: TokenError

Exception raised when no token can be parsed from request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when no token can be parsed from request.

authx.exceptions.MissingCSRFTokenError #

MissingCSRFTokenError(*args, login_type=None, **kwargs)

Bases: MissingTokenError

Exception raised when no CSRF token can be parsed from request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when no CSRF token can be parsed from request.

authx.exceptions.TokenTypeError #

TokenTypeError(*args, login_type=None, **kwargs)

Bases: TokenError

Exception raised when a specific token type is expected.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when token type is invalid.

authx.exceptions.LoginTypeMismatchError #

LoginTypeMismatchError(expected_type, actual_type=None, message=None, login_type=None)

Bases: TokenTypeError

Exception raised when a token belongs to a different login type.

Initialize LoginTypeMismatchError.

PARAMETER DESCRIPTION
expected_type

Login type required by the protected endpoint.

TYPE: str

actual_type

Login type found in the token, if it could be determined.

TYPE: Optional[str] DEFAULT: None

message

Optional custom error message.

TYPE: Optional[str] DEFAULT: None

login_type

The login_type to set on the base exception.

TYPE: Optional[str] DEFAULT: None

Source code in authx/exceptions.py
def __init__(
    self,
    expected_type: str,
    actual_type: Optional[str] = None,
    message: Optional[str] = None,
    login_type: Optional[str] = None,
) -> None:
    """Initialize LoginTypeMismatchError.

    Args:
        expected_type: Login type required by the protected endpoint.
        actual_type: Login type found in the token, if it could be determined.
        message: Optional custom error message.
        login_type: The login_type to set on the base exception.
    """
    self.expected_type = expected_type
    self.actual_type = actual_type
    actual = actual_type if actual_type is not None else "unknown"
    if message is None:
        message = f"Token type mismatch: expected '{expected_type}', got '{actual}'"
    super().__init__(message, login_type=login_type)

expected_type instance-attribute #

expected_type = expected_type

actual_type instance-attribute #

actual_type = actual_type

login_type instance-attribute #

login_type = login_type

Raised when a token belongs to a different login type than the protected endpoint expects.

authx.exceptions.RevokedTokenError #

RevokedTokenError(*args, login_type=None, **kwargs)

Bases: TokenError

Exception raised when a revoked token has been used.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when token is invalid.

authx.exceptions.TokenRequiredError #

TokenRequiredError(*args, login_type=None, **kwargs)

Bases: TokenError

Exception raised when no token was used in request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when token is required.

authx.exceptions.FreshTokenRequiredError #

FreshTokenRequiredError(*args, login_type=None, **kwargs)

Bases: TokenError

Exception raised when a not fresh token was used in request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when fresh token is required.

authx.exceptions.AccessTokenRequiredError #

AccessTokenRequiredError(*args, login_type=None, **kwargs)

Bases: TokenTypeError

Exception raised when an access token is missing from request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when access token is required.

authx.exceptions.RefreshTokenRequiredError #

RefreshTokenRequiredError(*args, login_type=None, **kwargs)

Bases: TokenTypeError

Exception raised when an refresh token is missing from request.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when refresh token is required.

authx.exceptions.PolicyDeniedError #

PolicyDeniedError(reason='Policy denied access', login_type=None)

Bases: TokenError

Exception raised when a policy evaluation denies access.

Initialize PolicyDeniedError.

PARAMETER DESCRIPTION
reason

Human-readable reason for the denial.

TYPE: str DEFAULT: 'Policy denied access'

login_type

The login_type to set on the base exception.

TYPE: Optional[str] DEFAULT: None

Source code in authx/exceptions.py
def __init__(self, reason: str = "Policy denied access", login_type: Optional[str] = None) -> None:
    """Initialize PolicyDeniedError.

    Args:
        reason: Human-readable reason for the denial.
        login_type: The login_type to set on the base exception.
    """
    self.reason = reason
    super().__init__(reason, login_type=login_type)

reason instance-attribute #

reason = reason

login_type instance-attribute #

login_type = login_type

Raised when policy evaluation denies access.

authx.exceptions.PolicyEvaluationError #

PolicyEvaluationError(*args, login_type=None, **kwargs)

Bases: AuthXException

Exception raised when a policy evaluator cannot be evaluated.

Initialize AuthXException.

PARAMETER DESCRIPTION
*args

Arguments for the exception.

TYPE: Any DEFAULT: ()

login_type

The login type associated with the exception.

TYPE: Optional[str] DEFAULT: None

**kwargs

Keyword arguments for the exception.

TYPE: Any DEFAULT: {}

Source code in authx/exceptions.py
def __init__(self, *args: Any, login_type: Optional[str] = None, **kwargs: Any) -> None:
    """Initialize AuthXException.

    Args:
        *args: Arguments for the exception.
        login_type: The login type associated with the exception.
        **kwargs: Keyword arguments for the exception.
    """
    self.login_type = login_type
    super().__init__(*args)

login_type instance-attribute #

login_type = login_type

Raised when a policy evaluator cannot be evaluated.

authx.exceptions.InvalidToken #

InvalidToken(errors)

Bases: Exception

When a token is invalid for all identity providers.

Initialize InvalidToken Exception.

PARAMETER DESCRIPTION
errors

list of errors

TYPE: list[str]

Source code in authx/exceptions.py
def __init__(self, errors: str) -> None:
    """Initialize InvalidToken Exception.

    Args:
        errors (list[str]): list of errors
    """
    self.errors = errors

errors instance-attribute #

errors = errors
 Raised when token is invalid.