Browse Source

feat: init KeycloakAdmin with token

pull/406/head
Jerónimo Mendes 2 years ago
parent
commit
fb0445c0c7
  1. 8
      src/keycloak/keycloak_admin.py

8
src/keycloak/keycloak_admin.py

@ -54,6 +54,8 @@ class KeycloakAdmin:
:type username: str :type username: str
:param password: admin password :param password: admin password
:type password: str :type password: str
:param token: access and refresh tokens
:type token: dict
:param totp: Time based OTP :param totp: Time based OTP
:type totp: str :type totp: str
:param realm_name: realm name :param realm_name: realm name
@ -88,7 +90,6 @@ class KeycloakAdmin:
_client_secret_key = None _client_secret_key = None
_auto_refresh_token = None _auto_refresh_token = None
_connection = None _connection = None
_token = None
_custom_headers = None _custom_headers = None
_user_realm_name = None _user_realm_name = None
@ -97,6 +98,7 @@ class KeycloakAdmin:
server_url, server_url,
username=None, username=None,
password=None, password=None,
token=None,
totp=None, totp=None,
realm_name="master", realm_name="master",
client_id="admin-cli", client_id="admin-cli",
@ -115,6 +117,8 @@ class KeycloakAdmin:
:type username: str :type username: str
:param password: admin password :param password: admin password
:type password: str :type password: str
:param token: access and refresh tokens
:type token: dict
:param totp: Time based OTP :param totp: Time based OTP
:type totp: str :type totp: str
:param realm_name: realm name :param realm_name: realm name
@ -139,6 +143,7 @@ class KeycloakAdmin:
self.server_url = server_url self.server_url = server_url
self.username = username self.username = username
self.password = password self.password = password
self.token = token
self.totp = totp self.totp = totp
self.realm_name = realm_name self.realm_name = realm_name
self.client_id = client_id self.client_id = client_id
@ -150,6 +155,7 @@ class KeycloakAdmin:
self.timeout = timeout self.timeout = timeout
# Get token Admin # Get token Admin
if not self.token:
self.get_token() self.get_token()
@property @property

Loading…
Cancel
Save