Welcome to keycloak_admin_aio’s documentation!¶
- Keycloak admin aio
- Types
- Instantiate a dataclass with keyword arguments
- Instantiate a dataclass with the from_dict class method
- Instantiate a list of dataclasses with the from_list class method
RoleRepresentation
RoleRepresentationComposites
ClientMappingsRepresentation
MappingsRepresentation
ProtocolMapperRepresentation
ClientScopeRepresentation
FederatedIdentityRepresentation
CredentialRepresentation
UserConsentRepresentation
UserRepresentation
GroupRepresentation
ScopeRepresentation
ResourceRepresentation
PolicyRepresentation
ResourceServerRepresentation
ClientRepresentation
RequiredActionProviderRepresentation
UserSession
- Keycloak resources
- Exceptions
What is keycloak_admin_aio?¶
This package provides an asynchronous api wrapper for the keycloak admin api.
The main dependencies are:
Links:
How to install?¶
pip install keycloak-admin-aio
How to use it?¶
import asyncio
from keycloak_admin_aio import KeycloakAdmin
server_url = "http://localhost:8080/auth"
client_id = "admin-cli" # used by default
realm = "master" # used by default
With administrator username and password:
keycloak_admin_args = {
"server_url": server_url,
"client_id": client_id,
"realm": realm,
"username": "admin",
"password": "password123",
}
async def main():
async with KeycloakAdmin.with_password(**keycloak_admin_args) as kc:
users = await kc.users.get(email="@google")
await asyncio.gather(
*[
kc.users.by_id(user.id).execute_actions_email.send_email(
["UPDATE_PASSWORD"]
)
for user in users
]
)
asyncio.run(main())
With client credentials:
keycloak_admin_args = {
"realm": realm,
"server_url": server_url,
"client_id": client_id,
"client_secret": "the_secret",
}
async def main():
async with KeycloakAdmin.with_client_credentials(**keycloak_admin_args) as kc:
...
asyncio.run(main())
License¶
© Copyright 2023, Nicklas Sedlock