diff --git a/keycloak/keycloak_admin.py b/keycloak/keycloak_admin.py index 41f4567..5725a1a 100644 --- a/keycloak/keycloak_admin.py +++ b/keycloak/keycloak_admin.py @@ -123,6 +123,7 @@ class KeycloakAdmin: _server_url = None _username = None _password = None + _totp = None _realm_name = None _client_id = None _verify = None @@ -138,6 +139,7 @@ class KeycloakAdmin: server_url, username=None, password=None, + totp=None, realm_name="master", client_id="admin-cli", verify=True, @@ -151,6 +153,7 @@ class KeycloakAdmin: :param server_url: Keycloak server url :param username: admin username :param password: admin password + :param totp: Time based OTP :param realm_name: realm name :param client_id: client id :param verify: True if want check connection SSL @@ -162,6 +165,7 @@ class KeycloakAdmin: self.server_url = server_url self.username = username self.password = password + self.totp = totp self.realm_name = realm_name self.client_id = client_id self.verify = verify @@ -237,6 +241,14 @@ class KeycloakAdmin: def password(self, value): self._password = value + @property + def totp(self): + return self._totp + + @totp.setter + def totp(self, value): + self._totp = value + @property def token(self): return self._token @@ -2434,7 +2446,7 @@ class KeycloakAdmin: if self.username and self.password: self._token = self.keycloak_openid.token( - self.username, self.password, grant_type=grant_type + self.username, self.password, grant_type=grant_type, totp=self.totp ) headers = {