code-specialist / fastapi-keycloak

Keycloak integration for Python FastAPI
https://fastapi-keycloak.code-specialist.com/
Apache License 2.0
192 stars 49 forks source link

Create clients from library #66

Open GratienDSX opened 2 years ago

GratienDSX commented 2 years ago

Hello there, thank you for this library that looks great.

I haven't found the possibility to create clients programmatically directly from the library, is it something planned? If not, I might open a PR to do so.

Jonatha-Varjao commented 2 years ago

Hi @GratienDSX , I think it's possible to create clients programmatically it'll be something like this

idp = FastAPIKeycloak(
    server_url="http://localhost:8085/auth",
    client_id="test-client",
    client_secret="GzgACcJzhzQ4j8kWhmhazt7WSdxDVUyE",
    admin_client_secret="BIcczGsZ6I8W5zf0rZg5qSexlloQLPKB",
    realm="Test",
    callback_uri="http://localhost:8081/callback"
)
idp.create_user(first_name=first_name, last_name=last_name, username=email, email=email, \
password=password.get_secret_value(), id=id)