geyanggang commented on code in PR #10317:
URL: https://github.com/apache/gravitino/pull/10317#discussion_r2908872578
##########
clients/client-python/gravitino/filesystem/gvfs_storage_handler.py:
##########
@@ -403,10 +412,50 @@ def get_filesystem_with_expiration(
catalog_props,
)
if isinstance(credential, GCSTokenCredential):
+ if not GOOGLE_AUTH_AVAILABLE:
+ raise GravitinoRuntimeException(
+ "Failed to import google.auth. "
+ "Please ensure google-auth is installed."
+ )
+
+ # gcsfs expects a google.auth.credentials.Credentials
object
+ # We need to create a credentials object from the access
token
+ class StaticCredentials(Credentials):
+ """A credentials object that uses a static access
token."""
+
+ def __init__(self, token_value, expiry_time_ms):
+ super().__init__()
+ self.token = token_value
+ # Convert milliseconds to datetime
+ self.expiry = datetime.fromtimestamp(
+ expiry_time_ms / 1000.0, tz=timezone.utc
+ )
+
+ def refresh(self, request):
+ # Static token cannot be refreshed
+ raise RuntimeError(
Review Comment:
Ok! Changed to raise `RefreshError` instead of `RuntimeError` so that
google-auth/gcsfs callers can handle it properly through their expected error
handling paths.
--
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]