kevinjqliu commented on code in PR #2072:
URL: https://github.com/apache/iceberg-python/pull/2072#discussion_r2252522970
##########
pyiceberg/catalog/rest/auth.py:
##########
@@ -119,6 +121,35 @@ def auth_header(self) -> str:
return f"Bearer {self._token}"
+class GoogleAuthManager(AuthManager):
+ """An auth manager that is responsible for handling Google credentials."""
+
+ def __init__(self, credentials_path: Optional[str] = None, scopes:
Optional[List[str]] = None):
+ """
+ Initialize GoogleAuthManager.
+
+ Args:
+ credentials_path: Optional path to Google credentials JSON file.
+ scopes: Optional list of OAuth2 scopes.
+ """
+ try:
+ import google.auth
+ import google.auth.transport.requests
+ except ImportError as e:
+ raise ImportError("Google Auth libraries not found. Please install
'google-auth'.") from e
+
+ if credentials_path:
+ self.credentials, _ =
google.auth.load_credentials_from_file(credentials_path, scopes=scopes)
+ else:
+ logger.info("Using Google Default Application Credentials")
+ self.credentials, _ = google.auth.default(scopes=scopes)
+ self._auth_request = google.auth.transport.requests.Request()
+
+ def auth_header(self) -> str:
+ self.credentials.refresh(self._auth_request)
Review Comment:
nit: is this `.refresh` called on every request?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]