Browse Source

fix: allow client_credentials token if username and password not specified

pull/324/head
Jackson Kwok 3 years ago
parent
commit
fe160531f4
No known key found for this signature in database GPG Key ID: BB88FE9481A0273D
  1. 8
      src/keycloak/keycloak_admin.py

8
src/keycloak/keycloak_admin.py

@ -2566,13 +2566,15 @@ class KeycloakAdmin:
custom_headers=self.custom_headers, custom_headers=self.custom_headers,
) )
grant_type = ["password"]
grant_type = []
if self.client_secret_key: if self.client_secret_key:
grant_type = ["client_credentials"]
if self.user_realm_name: if self.user_realm_name:
self.realm_name = self.user_realm_name self.realm_name = self.user_realm_name
grant_type.append("client_credentials")
elif self.username and self.password:
grant_type.append("password")
if self.username and self.password:
if grant_type:
self.token = self.keycloak_openid.token( self.token = self.keycloak_openid.token(
self.username, self.password, grant_type=grant_type, totp=self.totp self.username, self.password, grant_type=grant_type, totp=self.totp
) )

Loading…
Cancel
Save