I recently experienced an API error that is misleading and makes it difficult to understand the real problem.
I created a BQ table on a GSHEET drive file and I kept getting this error:
google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.
In reality, all permissions were correctly set and there was no reason for a permission denied.
I troubleshooted the error and I understood that the real problem was not having provided the scope:
https://www.googleapis.com/auth/drive
while instantiating the BigQuery Client.
[2022-10-28 09:29:24,569] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1683, in to_dataframe\n'
[2022-10-28 09:29:24,569] {pod_launcher.py:156} INFO - b' query_result = wait_for_query(self, progress_bar_type, max_results=max_results)\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/_tqdm_helpers.py", line 88, in wait_for_query\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' return query_job.result(max_results=max_results)\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1499, in result\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' do_get_result()\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/api_core/retry.py", line 283, in retry_wrapped_func\n'
[2022-10-28 09:29:24,570] {pod_launcher.py:156} INFO - b' return retry_target(\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/api_core/retry.py", line 190, in retry_target\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' return target()\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1489, in do_get_result\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' super(QueryJob, self).result(retry=retry, timeout=timeout)\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/job/base.py", line 728, in result\n'
[2022-10-28 09:29:24,571] {pod_launcher.py:156} INFO - b' return super(_AsyncJob, self).result(timeout=timeout, **kwargs)\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b' File "/usr/local/lib/python3.8/site-packages/google/api_core/future/polling.py", line 137, in result\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b' raise self._exception\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b'google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b'\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b'Location: EU\n'
[2022-10-28 09:29:24,572] {pod_launcher.py:156} INFO - b'Job ID: d09cdce0-7897-4de5-ae73-f5e27ca9d6ef\n'
[2022-10-28 09:29:24,573] {pod_launcher.py:156} INFO - b'\n'
Hi all,
I recently experienced an API error that is misleading and makes it difficult to understand the real problem.
I created a BQ table on a GSHEET drive file and I kept getting this error:
google.api_core.exceptions.Forbidden: 403 Access Denied: BigQuery BigQuery: Permission denied while getting Drive credentials.In reality, all permissions were correctly set and there was no reason for a permission denied.
I troubleshooted the error and I understood that the real problem was not having provided the scope:
https://www.googleapis.com/auth/drivewhile instantiating the BigQuery Client.
I believe that the error shown is misleading and should be:
insufficient scopesEnvironment details
google-cloud-bigqueryversion: 3.1.0Steps to reproduce
from google.cloud import bigqueryclient = bigquery.Client()query_job = client.query(query)df = query_job.to_dataframe()Stack trace
Thank you,
Stefano