From e68bbf22841a9e2062c7f02fdedf5331fd55749a Mon Sep 17 00:00:00 2001 From: Kevin Fox Date: Fri, 14 Jun 2019 13:11:08 -0700 Subject: [PATCH] Add the option to specify extra key/values to the token endpoint --- keycloak/keycloak_openid.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keycloak/keycloak_openid.py b/keycloak/keycloak_openid.py index ebd469f..61703e7 100644 --- a/keycloak/keycloak_openid.py +++ b/keycloak/keycloak_openid.py @@ -162,7 +162,7 @@ class KeycloakOpenID: "redirect-uri": redirect_uri} return URL_AUTH.format(**params_path) - def token(self, username="", password="", grant_type=["password"], code="", redirect_uri="", totp=None): + def token(self, username="", password="", grant_type=["password"], code="", redirect_uri="", totp=None, **extra): """ 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 @@ -183,6 +183,8 @@ class KeycloakOpenID: payload = {"username": username, "password": password, "client_id": self.client_id, "grant_type": grant_type, "code": code, "redirect_uri": redirect_uri} + if payload: + payload.update(extra) if totp: payload["totp"] = totp