added test lib

root 2021-05-21 18:53:39 +02:00
parent 974e5419c7
commit 7edd696d9a
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
from keycloak import KeycloakOpenID
# Configure client
keycloak_openid = KeycloakOpenID(server_url="http://isard-sso-keycloak:8080/auth/",
client_id="admin-cli",
realm_name="master",
client_secret_key="secret")
# Get WellKnow
config_well_know = keycloak_openid.well_know()
# Get Token
token = keycloak_openid.token("admin", "keycloakkeycloak")
#token = keycloak_openid.token("user", "password", totp="012345")
print(token)
from keycloak import KeycloakAdmin
keycloak_admin = KeycloakAdmin(server_url="http://isard-sso-keycloak:8080/auth/",
username='admin',
password='keycloakkeycloak',
realm_name="master",
verify=True)
# Add user
new_user = keycloak_admin.create_user({"email": "example@example.com",
"username": "example@example.com",
"enabled": True,
"firstName": "Example",
"lastName": "Example"})
print(new_user)