How To Suppress Python Error ‘google.api_core.exceptions.Forbidden: 403 GET https://bigquery.googleapis.com/bigquery/v2/projects/: Request had insufficient authentication scopes.’
We get this error ‘google.api_core.exceptions.Forbidden: 403 GET https://bigquery.googleapis.com/bigquery/v2/projects/XXXXX/queries/XXXXXXXX?maxResults=0&location=XX: Request had insufficient authentication scopes.’ when we are trying to operate BigQuery table though Python Code.
Solution: To solve this error we need to perform following steps :
- Download GCP Service account file with required privileges.
- Set following parameters in your python code
Import os
#Replace with service account path
path_service_account = ‘XXXXXXXXX.json’
os.environ[“GOOGLE_APPLICATION_CREDENTIALS”] = path_service_account