Skip to content

Commit

Permalink
address review comments: consolidate all optional into one method
Browse files Browse the repository at this point in the history
  • Loading branch information
hpal committed Mar 6, 2024
1 parent a4492f1 commit e878005
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit e878005

Please sign in to comment.