diff --git a/dbt/adapters/bigquery/credentials.py b/dbt/adapters/bigquery/credentials.py index 94d70a931..c7133e70f 100644 --- a/dbt/adapters/bigquery/credentials.py +++ b/dbt/adapters/bigquery/credentials.py @@ -4,11 +4,10 @@ from functools import lru_cache from typing import Any, Dict, Iterable, Optional, Tuple, Union -from google.auth import default +from google.auth import default, load_credentials_from_file, load_credentials_from_dict from google.auth.exceptions import DefaultCredentialsError from google.auth.impersonated_credentials import Credentials as ImpersonatedCredentials from google.oauth2.credentials import Credentials as GoogleCredentials -from google.oauth2.service_account import Credentials as ServiceAccountCredentials from mashumaro import pass_through from dbt_common.clients.system import run_cmd @@ -197,7 +196,7 @@ def _create_google_credentials(credentials: BigQueryCredentials) -> GoogleCreden creds, _ = _create_bigquery_defaults(scopes=credentials.scopes) elif credentials.method == _BigQueryConnectionMethod.SERVICE_ACCOUNT: - creds = ServiceAccountCredentials.from_service_account_file( + creds, _ = load_credentials_from_file( credentials.keyfile, scopes=credentials.scopes ) @@ -205,7 +204,7 @@ def _create_google_credentials(credentials: BigQueryCredentials) -> GoogleCreden details = credentials.keyfile_json if _is_base64(details): # type:ignore details = _base64_to_string(details) - creds = ServiceAccountCredentials.from_service_account_info( + creds, _ = load_credentials_from_dict( details, scopes=credentials.scopes ) diff --git a/pyproject.toml b/pyproject.toml index b2d55b25f..9535ef87a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ "google-cloud-dataproc~=5.0", # ---- # Expect compatibility with all new versions of these packages, so lower bounds only. + "google-auth>=2.20.0", "google-api-core>=2.11.0", # add dbt-core to ensure backwards compatibility of installation, this is not a functional dependency "dbt-core>=1.8.0",