Skip to content

Commit

Permalink
Update credentials when using ADC in Compute Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksYermak committed May 17, 2022
1 parent cd9d935 commit a9bd8b1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion airflow/providers/google/cloud/utils/credentials_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import google.auth
import google.auth.credentials
import google.oauth2.service_account
from google.auth import impersonated_credentials
from google.auth import compute_engine, impersonated_credentials
from google.auth.environment_vars import CREDENTIALS, LEGACY_PROJECT, PROJECT
from google.auth.transport import _http_client

from airflow.exceptions import AirflowException
from airflow.providers.google.cloud._internal_client.secret_manager_client import _SecretManagerClient
Expand Down Expand Up @@ -248,6 +249,9 @@ def get_credentials_and_project(self) -> Tuple[google.auth.credentials.Credentia

project_id = _get_project_id_from_service_account_email(self.target_principal)

if isinstance(credentials, compute_engine.Credentials):
credentials.refresh(_http_client.Request())

return credentials, project_id

def _get_credentials_using_keyfile_dict(self):
Expand Down

0 comments on commit a9bd8b1

Please sign in to comment.