Browse Source
Merge pull request #245 from ziyunxiao/master
fix invalid credential error and refresh_code not exist error
pull/247/head^2
Marcos Pereira
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
24 additions and
14 deletions
-
keycloak/keycloak_admin.py
|
|
@ -2106,7 +2106,13 @@ class KeycloakAdmin: |
|
|
|
return r |
|
|
|
|
|
|
|
def get_token(self): |
|
|
|
token_realm_name = self.user_realm_name or self.realm_name |
|
|
|
if self.user_realm_name: |
|
|
|
token_realm_name = self.user_realm_name |
|
|
|
elif self.realm_name: |
|
|
|
token_realm_name = self.realm_name |
|
|
|
else: |
|
|
|
token_realm_name = "master" |
|
|
|
|
|
|
|
self.keycloak_openid = KeycloakOpenID(server_url=self.server_url, client_id=self.client_id, |
|
|
|
realm_name=token_realm_name, verify=self.verify, |
|
|
|
client_secret_key=self.client_secret_key, |
|
|
@ -2139,7 +2145,10 @@ class KeycloakAdmin: |
|
|
|
verify=self.verify) |
|
|
|
|
|
|
|
def refresh_token(self): |
|
|
|
refresh_token = self.token.get('refresh_token') |
|
|
|
refresh_token = self.token.get('refresh_token', None) |
|
|
|
if refresh_token is None: |
|
|
|
self.get_token() |
|
|
|
else: |
|
|
|
try: |
|
|
|
self.token = self.keycloak_openid.refresh_token(refresh_token) |
|
|
|
except KeycloakGetError as e: |
|
|
@ -2152,6 +2161,7 @@ class KeycloakAdmin: |
|
|
|
self.get_token() |
|
|
|
else: |
|
|
|
raise |
|
|
|
|
|
|
|
self.connection.add_param_headers('Authorization', 'Bearer ' + self.token.get('access_token')) |
|
|
|
|
|
|
|
def get_client_all_sessions(self, client_id): |
|
|
|