diff --git a/llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py b/llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py index 31fb0b0d557083d5e713d3c0cb3fd4705bf63a60..3b8f6b8dc9b721ee776c95fa2d58210c42dae362 100644 --- a/llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py +++ b/llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py @@ -43,6 +43,7 @@ class GCSReader(BasePydanticReader): Default is None. service_account_key (Optional[Dict[str, str]]): provide GCP service account key directly. service_account_key_json (Optional[str]): provide GCP service account key as a JSON string. + service_account_key_path (Optional[str]): provide path to file containing GCP service account key. """ is_remote: bool = True @@ -60,6 +61,7 @@ class GCSReader(BasePydanticReader): file_metadata: Optional[Callable[[str], Dict]] = Field(default=None, exclude=True) service_account_key: Optional[Dict[str, str]] = None service_account_key_json: Optional[str] = None + service_account_key_path: Optional[str] = None @classmethod def class_name(cls) -> str: @@ -74,9 +76,13 @@ class GCSReader(BasePydanticReader): self.service_account_key, scopes=SCOPES ) elif self.service_account_key_json is not None: - creds = service_account.Credentials.from_service_account_file( + creds = service_account.Credentials.from_service_account_info( json.loads(self.service_account_key_json), scopes=SCOPES ) + elif self.service_account_key_path is not None: + creds = service_account.Credentials.from_service_account_file( + self.service_account_key_path, scopes=SCOPES + ) else: # Use anonymous access if none are specified creds = "anon"