This library wraps the Keycloak REST API, providing an easy way to manage users, clients, and other Keycloak resources. It’s simple, extendable, and has been tested in production.
$ pip install python-keycloak-api-client
from keycloak_api_client import KeycloakApiClient
client = KeycloakApiClient(
keycloak_url: "https://auth.myservice.com",
realm: "myservice",
admin_username: "my_keycloak_admin",
admin_password: "...",
admin_client_id: "my_service_backend_client_id",
admin_client_secret: "...",
relative_path: "/auth",
)
read_kc_user = client.get_keycloak_user_by_email('johndoe@myservice.com')
read_kc_user.email # johndoe@myservice.com
read_kc_user.enabled # True
read_kc_user.first_name # John
read_kc_user.last_name # Doe
...
# Run linter and tests for all Python versions
$ tox
# Format
$ ruff format
# Check
$ ruff check
$ pip install -e .