Browse Source

Fix KeycloakAdmin using wrong realm when authenticating with a service account

Signed-off-by: Jacky Boen <jacky@veand.co>
pull/219/head
Jacky Boen 3 years ago
parent
commit
a9b3924854
No known key found for this signature in database GPG Key ID: 89E603474AB6BFB
  1. 5
      keycloak/keycloak_admin.py

5
keycloak/keycloak_admin.py

@ -1827,14 +1827,17 @@ class KeycloakAdmin:
return r
def get_token(self):
token_realm_name = 'master' if self.client_secret_key else self.user_realm_name or self.realm_name
self.keycloak_openid = KeycloakOpenID(server_url=self.server_url, client_id=self.client_id,
realm_name=self.user_realm_name or self.realm_name, verify=self.verify,
realm_name=token_realm_name, verify=self.verify,
client_secret_key=self.client_secret_key,
custom_headers=self.custom_headers)
grant_type = ["password"]
if self.client_secret_key:
grant_type = ["client_credentials"]
if self.user_realm_name:
self.realm_name = self.user_realm_name
self._token = self.keycloak_openid.token(self.username, self.password, grant_type=grant_type)

Loading…
Cancel
Save