Skip to main content

async keycloak admin api wrapper

Project description

What is keycloak_admin_aio?

This package provides an asynchronous api wrapper for the keycloak admin api.

The main dependencies are:

  • httpx: asynchronous http client

  • dacite: parse nested dictionaries into nested dataclasses

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

Apache License, Version 2.0

© Copyright 2023, Nicklas Sedlock

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keycloak_admin_aio-1.3.7.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

keycloak_admin_aio-1.3.7-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

Details for the file keycloak_admin_aio-1.3.7.tar.gz.

File metadata

File hashes

Hashes for keycloak_admin_aio-1.3.7.tar.gz
Algorithm Hash digest
SHA256 25ee258a09e1db3ae9ff1a2b383357e96964bb2636704904338a89cae9ab99a5
MD5 cf80186fe044d106b30442fbfd9be640
BLAKE2b-256 9b30014674089928e94a9a2f5bf4a188b7e379327a8ffc941be08ebeb24e52ee

See more details on using hashes here.

File details

Details for the file keycloak_admin_aio-1.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for keycloak_admin_aio-1.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c089d525fd52ed176427498927064ba838bfaa2c25e788b6a7028e52b350646e
MD5 b6bc72364bffaee5f4e8e0d4de931289
BLAKE2b-256 b6a823023b2cc52d9459b47f2ff1b2b1971cf7e097868b110b0c259e087152ad

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page