m1racoli commented on code in PR #36341: URL: https://github.com/apache/airflow/pull/36341#discussion_r1454943542
########## airflow/providers/google/cloud/hooks/bigquery.py: ########## @@ -3247,6 +3259,36 @@ def _format_schema_for_description(schema: dict) -> list: return description +class ImpersonationToken: + """Simulate the interface of gcloud.aio.auth.token.BaseToken and generate impersonation_chain access_token.""" + + def __init__(self, project_id: str | None, impersonation_chain: str) -> None: + self.project_id = project_id + self.impersonation_chain = impersonation_chain + + async def get_project(self) -> str | None: + project = ( + self.project_id + or os.environ.get("GOOGLE_CLOUD_PROJECT") + or os.environ.get("GCLOUD_PROJECT") + or os.environ.get("APPLICATION_ID") + ) + return project + + async def get(self) -> str | None: + creds, _ = google.auth.default() Review Comment: Instead of getting default credentials, we should retrieve the credentials for a given connection ID here, no? Furthermore, I was looking at other Google hooks which work fine asyncronously with impersonation chain and noticed that for example the [DataprocAsyncHook](https://github.com/apache/airflow/blob/9b5d6bfe273cf6af0972e28ff97f99ea325cd991/airflow/providers/google/cloud/hooks/dataproc.py#L1085) (subclass of GoogleBaseHook) just calls `self.get_credentials()`. I suppose this itself (creating a credentials object) is non-blocking until we want to actually generate a token for the given credentials, or? So I wonder if we maybe just have to implement `credentials -> token` asynchronously? That's probably what Google's async clients do under the hood, but unfortunately we're here also because there is no async client for [BigQuery](https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.client.Client) to begin with. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org