0

When attempting to use the GoogleDriveToGCSOperator via a Service Account, I am only able to interact with folders I create directly within the My Drive path in Drive. If I use a different Team/Shared Drive, I receive errors even though the Team drive has also granted permissions to the Service Account.

    upload_gdrive_to_gcs = GoogleDriveToGCSOperator(
        task_id="upload_gdrive_object_to_gcs",
        folder_id="my-folder-id-here",
        file_name="abc.txt",
        bucket_name="gdrive-testbucket",
        object_name="testfile.txt",
        gcp_conn_id='google_cloud_default',
    )

This operator for example produces the below error when trying to use the Team drive:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py", line 126, in execute
    gdrive_hook.download_file(file_id=file_metadata["id"], file_handle=file)
KeyError: 'id'

But if I simply switch the folder_id to a folder within my own My Drive path, it is successful. Both My Drive and the shared Team drive are sharing the same access/permissions to the service account.

Has anyone run into this and were able to get these operators to work with the Team drive folders?

phenderbender
  • 625
  • 2
  • 8
  • 18
  • 1
    Do you know if `GoogleDriveToGCSOperator` supports Team/Shared Drive? some applications or platforms do not support Team/Shared Drive since it depends on the methods that it's used to make the calls. For example, the method [Drives: list](https://developers.google.com/drive/api/v3/reference/drives/list) does not support the listing of files inside Team/Shared Drive. However, you can use the method [Files: list](https://developers.google.com/drive/api/v3/reference/files/list) to list files and folders inside of a Team/Shared Drive. – Giselle Valladares Jun 16 '22 at 18:37
  • thanks @GiselleValladares yes it does, I realized shared drives must include the `drive_id` param in the operator, while My Drive files only require `folder_id` – phenderbender Jun 17 '22 at 13:12

1 Answers1

1

In order to interact with files in a team shared drive you must include the drive_id param in the operator (which looks like a folder ID at the end of the URL when you are in the root of the shared drive). Otherwise it assumes you are looking for a file in My Drive (which only requires the folder_id)

phenderbender
  • 625
  • 2
  • 8
  • 18