Browse Source
fix: allow client_credentials token if username and password not specified
pull/324/head
Jackson Kwok
3 years ago
No known key found for this signature in database
GPG Key ID: BB88FE9481A0273D
1 changed files with
5 additions and
3 deletions
-
src/keycloak/keycloak_admin.py
|
|
@ -2566,13 +2566,15 @@ class KeycloakAdmin: |
|
|
|
custom_headers=self.custom_headers, |
|
|
|
) |
|
|
|
|
|
|
|
grant_type = ["password"] |
|
|
|
grant_type = [] |
|
|
|
if self.client_secret_key: |
|
|
|
grant_type = ["client_credentials"] |
|
|
|
if 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.username, self.password, grant_type=grant_type, totp=self.totp |
|
|
|
) |
|
|
|