From e878005fcdeb041dec2c17e1fd85a3064e8067ec Mon Sep 17 00:00:00 2001 From: hpal Date: Wed, 6 Mar 2024 08:43:06 -0800 Subject: [PATCH] address review comments: consolidate all optional into one method --- pyiceberg/catalog/rest.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 90abee0fab..79fc37a398 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -292,8 +292,8 @@ def auth_url(self) -> str: return self.url(Endpoints.get_token, prefixed=False) def _extract_optional_oauth_params(self) -> Dict[str, str]: + optional_oauth_param = {SCOPE: self.properties.get(SCOPE) or CATALOG_SCOPE} set_of_optional_params = {AUDIENCE, RESOURCE} - optional_oauth_param = {} for param in set_of_optional_params: if param_value := self.properties.get(param): optional_oauth_param[param] = param_value @@ -306,10 +306,7 @@ def _fetch_access_token(self, session: Session, credential: str) -> str: else: client_id, client_secret = None, credential - # take scope from properties or use default CATALOG_SCOPE - scope = self.properties.get(SCOPE) or CATALOG_SCOPE - - data = {GRANT_TYPE: CLIENT_CREDENTIALS, CLIENT_ID: client_id, CLIENT_SECRET: client_secret, SCOPE: scope} + data = {GRANT_TYPE: CLIENT_CREDENTIALS, CLIENT_ID: client_id, CLIENT_SECRET: client_secret} optional_oauth_params = self._extract_optional_oauth_params() data.update(optional_oauth_params)