keycloak.exceptions

Keycloak custom exceptions module.

Exceptions

KeycloakError

Base class for custom Keycloak errors.

KeycloakAuthenticationError

Keycloak authentication error exception.

KeycloakConnectionError

Keycloak connection error exception.

KeycloakOperationError

Keycloak operation error exception.

KeycloakDeprecationError

Keycloak deprecation error exception.

KeycloakGetError

Keycloak request get error exception.

KeycloakPostError

Keycloak request post error exception.

KeycloakPutError

Keycloak request put error exception.

KeycloakDeleteError

Keycloak request delete error exception.

KeycloakSecretNotFound

Keycloak secret not found exception.

KeycloakRPTNotFound

Keycloak RPT not found exception.

KeycloakAuthorizationConfigError

Keycloak authorization config exception.

KeycloakInvalidTokenError

Keycloak invalid token exception.

KeycloakPermissionFormatError

Keycloak permission format exception.

PermissionDefinitionError

Keycloak permission definition exception.

Functions

raise_error_from_response(response, error[, ...])

Raise an exception for the response.

Module Contents

exception keycloak.exceptions.KeycloakError(error_message='', response_code=None, response_body=None)[source]

Bases: Exception

Base class for custom Keycloak errors.

Parameters:
  • error_message (str) – The error message

  • response_code (int) – The response status code

response_code = None[source]
response_body = None[source]
error_message = ''[source]
__str__()[source]

Str method.

Returns:

String representation of the object

Return type:

str

exception keycloak.exceptions.KeycloakAuthenticationError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakError

Keycloak authentication error exception.

exception keycloak.exceptions.KeycloakConnectionError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakError

Keycloak connection error exception.

exception keycloak.exceptions.KeycloakOperationError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakError

Keycloak operation error exception.

exception keycloak.exceptions.KeycloakDeprecationError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakError

Keycloak deprecation error exception.

exception keycloak.exceptions.KeycloakGetError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak request get error exception.

exception keycloak.exceptions.KeycloakPostError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak request post error exception.

exception keycloak.exceptions.KeycloakPutError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak request put error exception.

exception keycloak.exceptions.KeycloakDeleteError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak request delete error exception.

exception keycloak.exceptions.KeycloakSecretNotFound(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak secret not found exception.

exception keycloak.exceptions.KeycloakRPTNotFound(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak RPT not found exception.

exception keycloak.exceptions.KeycloakAuthorizationConfigError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak authorization config exception.

exception keycloak.exceptions.KeycloakInvalidTokenError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak invalid token exception.

exception keycloak.exceptions.KeycloakPermissionFormatError(error_message='', response_code=None, response_body=None)[source]

Bases: KeycloakOperationError

Keycloak permission format exception.

exception keycloak.exceptions.PermissionDefinitionError[source]

Bases: Exception

Keycloak permission definition exception.

keycloak.exceptions.raise_error_from_response(response, error, expected_codes=None, skip_exists=False)[source]

Raise an exception for the response.

Parameters:
  • response (Response) – The response object

  • error (dict or Exception) – Error object to raise

  • expected_codes (Sequence[int]) – Set of expected codes, which should not raise the exception

  • skip_exists (bool) – Indicates whether the response on already existing object should be ignored

Returns:

Content of the response message

Type:

bytes or dict

Raises:

KeycloakError – In case of unexpected status codes