diff --git a/keycloak/keycloak_openid.py b/keycloak/keycloak_openid.py index ad25c1d..9315a2b 100644 --- a/keycloak/keycloak_openid.py +++ b/keycloak/keycloak_openid.py @@ -173,7 +173,8 @@ class KeycloakOpenID: """ params_path = {"realm-name": self.realm_name} - data_raw = self.connection.raw_get(URL_WELL_KNOWN.format(**params_path)) + data_raw = self.connection.raw_get( + URL_WELL_KNOWN.format(**params_path)) return raise_error_from_response(data_raw, KeycloakGetError) @@ -235,7 +236,8 @@ class KeycloakOpenID: :return: """ params_path = {"realm-name": self.realm_name} - payload = {"client_id": self.client_id, "grant_type": grant_type, "refresh_token": refresh_token} + payload = {"client_id": self.client_id, + "grant_type": grant_type, "refresh_token": refresh_token} payload = self._add_secret_key(payload) data_raw = self.connection.raw_post(URL_TOKEN.format(**params_path), data=payload) @@ -287,7 +289,7 @@ class KeycloakOpenID: params_path = {"realm-name": self.realm_name} data_raw = self.connection.raw_get(URL_CERTS.format(**params_path)) return raise_error_from_response(data_raw, KeycloakGetError) - + def public_key(self): """ The public key is exposed by the realm page directly. @@ -309,10 +311,12 @@ class KeycloakOpenID: :return: """ self.connection.add_param_headers("Authorization", "Bearer " + token) - params_path = {"realm-name": self.realm_name, "resource-server-id": resource_server_id} - data_raw = self.connection.raw_get(URL_ENTITLEMENT.format(**params_path)) - - if data_raw.status_code == 404: + params_path = {"realm-name": self.realm_name, + "resource-server-id": resource_server_id} + data_raw = self.connection.raw_get( + URL_ENTITLEMENT.format(**params_path)) + + if data_raw.status_code == 404: return raise_error_from_response(data_raw, KeycloakDeprecationError) return raise_error_from_response(data_raw, KeycloakGetError) @@ -336,8 +340,10 @@ class KeycloakOpenID: if token_type_hint == 'requesting_party_token': if rpt: - payload.update({"token": rpt, "token_type_hint": token_type_hint}) - self.connection.add_param_headers("Authorization", "Bearer " + token) + payload.update( + {"token": rpt, "token_type_hint": token_type_hint}) + self.connection.add_param_headers( + "Authorization", "Bearer " + token) else: raise KeycloakRPTNotFound("Can't found RPT.")