I'm trying to run a query with bq cli that joins data from a table that is connected to Google Sheets and another table on Bigquery. I'm running this on a instance on Google Compute Engine, but i'm getting this error:
Access Denied: BigQuery BigQuery: No OAuth token with Google Drive scope was found.
I took a look and found that I need to change the scopes, but my instance is already with the setting "Allow full access to all Cloud APIs".
Anyone knows how to solve this?
Thanks
The problem is that Drive is not part of the Cloud APIs. It belongs to the GSuite Activity API. See here. Thus, the scope for Drive (https://www.googleapis.com/auth/drive) is not enabled for the service account on your GCE instance.
Here's what you need to do:
gcloud compute instances create [YOUR-PREFERRED-INSTANCE-NAME] --scopes=https://www.googleapis.com/auth/drive,https:/
/www.googleapis.com/auth/bigquery --zone=[YOUR-PREFERRED-ZONE]bq query "SELECT * FROM [grey-sort-challenge:sheets_test.test]".Using a BigQuery table that is backed by a test sheet in Drive, I initially got the same error as you. However, after setting the scopes as above, it now works:


Now, in my test/example I created an instance from scratch (step 2). But, if you'd like to modify an existing instance you'll need to stop that instance, and then update the scopes using the gcloud beta compute instances set-scopes command. See here.
Note: when you set the scopes that way, you will clobber any existing scopes that have been set - so make sure to enter all the scopes that you need e.g.: gcloud beta compute instances set-scopes [INSTANCE-NAME] --scopes=https://www.googleapis.com/auth/drive,https://
www.googleapis.com/auth/bigquery,...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With