I am trying to read data from the external bigquery table (i.e. linked to google sheet) in apache beam pipeline as below and later loading into bigquery table only. But the code getting failed with below error during reading data,
Error: "Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials."
with beam.Pipeline(options=google_cloud_options) as p:
# Step 1: Get URL list from BigQuery table
urls = (
p | 'Get URLs from BQ Table' >> beam.io.ReadFromBigQuery(
query="""
SELECT cast(id as INT64) AS site_id, url
FROM `my-project.my_dashboard.MAP_URLS_GSHEET`
""",
use_standard_sql=True
)
)
I am using service account which have access to the google sheet as viewer and also to BQ database.
Note: The same code is working in Dataflow while using native BQ table instead of external table.
Could you please help here , how to solve this issue i.e. specially when running through dataflow?
Hi Trushasahu,
Does your service account have the following roles aside from viewer access?
Hello Aris,
Still getting the same error 'Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.'
The problem is here that the bigquery table is linked to the google sheet. So getting access denied for this only even though the service account has the view access to this google sheet.
Could you resolve the issue ?
Here are some possible checking you may try to perform:
Double-check that the BigQuery table is linked to the appropriate Google Sheet by checking the link between the two. To do this, open the BigQuery console, locate the needed table, and select "Details" from the drop-down menu in the top-right corner. After that, make sure the "Source" field refers to the proper Google Sheet by checking it.
In the event that all other attempts to link the BigQuery table to the Google Sheet are unsuccessful, try linking the BigQuery table again. To do this, open the BigQuery console, locate the needed table, and select "Details" from the drop-down menu in the top-right corner. In order to remove the table from the Google Sheet, click "Unlink" next. After that, click "Link" and adhere to the instructions to re-link the table to Google Sheet.
Hope this helps.
Hi Aris_O/Team,
While access from VM using individual ID/User define service account ,we are able to access the data from BQ (has external table with Gsheet) . When trying with default service account getting theBigQuery: Permission denied while getting Drive credentials.
Any lead please
Unlink is no longer an option.
@Aris_O wrote:Verify the Google Sheet's permissions to ensure that the service account has at least "Viewer" access. Open the Google Sheet, then click "Share" in the top-right corner to accomplish this. Add the service account's email address that has "Viewer" access after that.
With de service email as a viewer worked as a charm. Thanks
Hi
Team,
While access from VM using individual ID/User define service account ,we are able to access the data from BQ (has external table with Gsheet) . When trying with default service account /service account attached with VM (by give full Cloud api scope) getting theBigQuery: Permission denied while getting Drive credentials.
Any lead please
Hi All,
I think what you need to do is to set the scope of the VM with the service account as in the following example.
gcloud beta compute instances stop google-drive-test --zone=europe-west1-c
gcloud beta compute instances set-scopes google-drive-test \
--scopes=default,cloud-platform,https://www.googleapis.com/auth/drive \
--zone=europe-west1-c \
--service-account=0123456789012-compute@developer.gserviceaccount.com
gcloud beta compute instances start google-drive-test --zone=europe-west1-c
I was running through the same issue and it was fixed when I added the service account to the list of users with access to the Google Sheets. I hope that helps.
Refer to this stack overflow. It worked for me. You have to explicitly define scopes though you are querying BigQuery
https://stackoverflow.com/users/29967373/user29967373
This links to a user.