diff --git a/parsons/google/google_bigquery.py b/parsons/google/google_bigquery.py index 2ae3aa8337..e751e4e9bb 100644 --- a/parsons/google/google_bigquery.py +++ b/parsons/google/google_bigquery.py @@ -141,15 +141,32 @@ class GoogleBigQuery(DatabaseConnector): then will use the default inferred environment. location: str Default geographic location for tables + client_options: dict + A dictionary containing any requested client options. Defaults to the required + scopes for making API calls against External tables stored in Google Drive. + Can be set to None if these permissions are not desired """ - def __init__(self, app_creds=None, project=None, location=None): + def __init__( + self, + app_creds=None, + project=None, + location=None, + client_options: dict = { + "scopes": [ + "https://www.googleapis.com/auth/drive", + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ] + }, + ): self.app_creds = app_creds setup_google_application_credentials(app_creds) self.project = project self.location = location + self.client_options = client_options # We will not create the client until we need to use it, since creating the client # without valid GOOGLE_APPLICATION_CREDENTIALS raises an exception. @@ -170,7 +187,11 @@ def client(self): """ if not self._client: # Create a BigQuery client to use to make the query - self._client = bigquery.Client(project=self.project, location=self.location) + self._client = bigquery.Client( + project=self.project, + location=self.location, + client_options=self.client_options, + ) return self._client