Keycloak admin aio¶
This package provides a asynchronous Keycloak Admin API wrapper.
Reference¶
- class keycloak_admin_aio.KeycloakAdmin¶
Base class for Keycloak Admin API endpoints.
It handles the
access_token
and guarantees it being valid when using theget_access_token
method or accessing a protected Keycloak resource.- client_scopes: ClientScopes¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#_client_scopes
- admin_events: AdminEvents¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#_realms_admin
- authentication: Authentication¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#_authentication_management
- attack_detection: AttackDetection¶
https://www.keycloak.org/docs-api/26.0.0/rest-api/index.html#_attack_detection
- __init__(server_url, grant_type, username=None, password=None, client_id=None, client_secret=None, realm='master', leeway=10, httpx_args={})¶
Initialize
KeycloakAdmin
with either client or user credentials.Should not be used directly. The usage of
with_client_credentials
orwith_password
should be preferred.- Parameters:
server_url (str)
grant_type (Literal['client_credentials', 'password'])
username (str | None)
password (str | None)
client_id (str | None)
client_secret (str | None)
realm (str)
leeway (int)
- leeway: int¶
A token will be considered as expired seconds before its actual expiry controlled by this value.
- classmethod with_client_credentials(server_url, client_id, client_secret, realm='master', leeway=10, httpx_args={})¶
Instantiate
KeycloakAdmin
withclient_id
andclient_secret
.- Parameters:
server_url (str)
client_id (str)
client_secret (str)
realm (str)
leeway (int)
- Return type:
- classmethod with_password(server_url, username=None, password=None, client_id='admin-cli', realm='master', leeway=10, httpx_args={})¶
Instantiate
KeycloakAdmin
with user credentials (username and password).- Parameters:
server_url (str)
username (str | None)
password (str | None)
client_id (str | None)
realm (str)
leeway (int)
- Return type:
- property realm¶
Realm property.
- property username¶
Username property.
- property client_id¶
Client id property.
- property client_secret¶
Client secret property.
- property password¶
Password property.
- property server_url¶
Server url property.
- property grant_type¶
Token endpoint grant type.
- get_url()¶
Get the admin api base url.
- async close()¶
Closes open httpx connection.
- close_sync()¶
Synchronously close open httpx connection.
- async get_access_token()¶
Get
access_token
. Guaranteed not to be expired.
- get_token_url()¶
Openid connect token endpoint url.
- Return type:
str