Browse Source

support totp

pull/12/head
Alain ROMEYER 6 years ago
parent
commit
74da5c2ee6
  1. 6
      keycloak/keycloak_openid.py

6
keycloak/keycloak_openid.py

@ -158,7 +158,7 @@ class KeycloakOpenID:
""" """
return NotImplemented return NotImplemented
def token(self, username="", password="", grant_type=["password"], code="", redirect_uri=""):
def token(self, username="", password="", grant_type=["password"], code="", redirect_uri="", totp=None):
""" """
The token endpoint is used to obtain tokens. Tokens can either be obtained by The token endpoint is used to obtain tokens. Tokens can either be obtained by
exchanging an authorization code or by supplying credentials directly depending on exchanging an authorization code or by supplying credentials directly depending on
@ -172,6 +172,7 @@ class KeycloakOpenID:
:param grant_type: :param grant_type:
:param code: :param code:
:param redirect_uri :param redirect_uri
:param totp
:return: :return:
""" """
params_path = {"realm-name": self.realm_name} params_path = {"realm-name": self.realm_name}
@ -179,6 +180,9 @@ class KeycloakOpenID:
"client_id": self.client_id, "grant_type": grant_type, "client_id": self.client_id, "grant_type": grant_type,
"code": code, "redirect_uri": redirect_uri} "code": code, "redirect_uri": redirect_uri}
if totp:
payload["totp"] = totp
payload = self._add_secret_key(payload) payload = self._add_secret_key(payload)
data_raw = self.connection.raw_post(URL_TOKEN.format(**params_path), data_raw = self.connection.raw_post(URL_TOKEN.format(**params_path),
data=payload) data=payload)

Loading…
Cancel
Save