Browse Source

feat: add custom_headers to KeycloakOpenID in get_token()

pull/490/head
Anton Velychko 2 years ago
parent
commit
8e920e12ca
  1. 8
      src/keycloak/openid_connection.py

8
src/keycloak/openid_connection.py

@ -110,21 +110,20 @@ class KeycloakOpenIDConnection(ConnectionManager):
self.client_id = client_id self.client_id = client_id
self.verify = verify self.verify = verify
self.client_secret_key = client_secret_key self.client_secret_key = client_secret_key
self.custom_headers = custom_headers
self.user_realm_name = user_realm_name self.user_realm_name = user_realm_name
self.timeout = timeout self.timeout = timeout
if self.token is None: if self.token is None:
self.get_token() self.get_token()
self.headers = (
if self.token is not None:
self.headers.update(
{ {
"Authorization": "Bearer " + self.token.get("access_token"), "Authorization": "Bearer " + self.token.get("access_token"),
"Content-Type": "application/json", "Content-Type": "application/json",
} }
if self.token is not None
else {}
) )
self.custom_headers = custom_headers
super().__init__( super().__init__(
base_url=self.server_url, headers=self.headers, timeout=60, verify=self.verify base_url=self.server_url, headers=self.headers, timeout=60, verify=self.verify
@ -293,6 +292,7 @@ class KeycloakOpenIDConnection(ConnectionManager):
realm_name=token_realm_name, realm_name=token_realm_name,
verify=self.verify, verify=self.verify,
client_secret_key=self.client_secret_key, client_secret_key=self.client_secret_key,
custom_headers=self.custom_headers,
timeout=self.timeout, timeout=self.timeout,
) )

Loading…
Cancel
Save