anu
anu

Reputation: 41

Upload GCS File to Google Drive (Airflow)

I am using airflow.providers.google.suite.transfers.gcs_to_gdrive.GCSToGoogleDriveOperator to upload a file from GCS to Google Drive.

Getting 403 Forbidden with reason "insufficientPermissions"

This is the logging. Not sure where and what the issue is. any help is highly appreciated !!!

Code

    from airflow.providers.google.suite.transfers.gcs_to_gdrive import GCSToGoogleDriveOperator  
    copy_google_adwords_from_gcs_to_google_drive = GCSToGoogleDriveOperator(
        task_id="copy_google_adwords_from_gcs_to_google_drive",
        source_bucket="{}".format(gcs_to_gdrive_bucket),
        source_object="conversion_data.csv",
        destination_object="adwords_data/",
        gcp_conn_id='google_cloud_default',
       dag=dag
    )

In the gcp_conn_id = google_cloud_default. I have added the scope = https://www.googleapis.com/auth/drive

Upvotes: 0

Views: 862

Answers (1)

phenderbender
phenderbender

Reputation: 785

In your airflow connection, in the scopes field, try adding:

https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/cloud-platform

You'll also need to ensure the service account has the correct roles assigned (as well as the drive being shared w/ the Service Account's email)

Some of the roles you can add to the service account by going to IAM > click edit on the service account, and add the roles

Roles

Upvotes: 1

Related Questions