|
18 | 18 | import google.cloud.bigquery as bigquery |
19 | 19 | import google.cloud.exceptions |
20 | 20 | from google.api_core import retry, client_info |
21 | | -from google.auth import impersonated_credentials |
22 | | -from google.oauth2 import ( |
23 | | - credentials as GoogleCredentials, |
24 | | - service_account as GoogleServiceAccountCredentials, |
| 21 | +from google.auth import ( |
| 22 | + impersonated_credentials, |
| 23 | + load_credentials_from_file, |
| 24 | + load_credentials_from_dict, |
25 | 25 | ) |
26 | | - |
| 26 | +from google.oauth2 import credentials as GoogleCredentials, |
27 | 27 | from dbt.adapters.bigquery import gcloud |
28 | 28 | from dbt.clients import agate_helper |
29 | 29 | from dbt.config.profile import INVALID_PROFILE_MESSAGE |
@@ -332,19 +332,20 @@ def format_rows_number(self, rows_number): |
332 | 332 | @classmethod |
333 | 333 | def get_google_credentials(cls, profile_credentials) -> GoogleCredentials: |
334 | 334 | method = profile_credentials.method |
335 | | - creds = GoogleServiceAccountCredentials.Credentials |
336 | 335 |
|
337 | 336 | if method == BigQueryConnectionMethod.OAUTH: |
338 | 337 | credentials, _ = get_bigquery_defaults(scopes=profile_credentials.scopes) |
339 | 338 | return credentials |
340 | 339 |
|
341 | 340 | elif method == BigQueryConnectionMethod.SERVICE_ACCOUNT: |
342 | 341 | keyfile = profile_credentials.keyfile |
343 | | - return creds.from_service_account_file(keyfile, scopes=profile_credentials.scopes) |
| 342 | + credentials, _ = load_credentials_from_file(keyfile, scopes=profile_credentials.scopes) |
| 343 | + return credentials |
344 | 344 |
|
345 | 345 | elif method == BigQueryConnectionMethod.SERVICE_ACCOUNT_JSON: |
346 | 346 | details = profile_credentials.keyfile_json |
347 | | - return creds.from_service_account_info(details, scopes=profile_credentials.scopes) |
| 347 | + credentials, _ = load_credentials_from_dict(details, scopes=profile_credentials.scopes) |
| 348 | + return credentials |
348 | 349 |
|
349 | 350 | elif method == BigQueryConnectionMethod.OAUTH_SECRETS: |
350 | 351 | return GoogleCredentials.Credentials( |
|
0 commit comments