airflow.providers.google.cloud.utils.credentials_provider

This module contains a mechanism for providing temporary Google Cloud authentication.

Module Contents

Functions

build_gcp_conn([key_file_path, scopes, project_id])

Build a uri that can be used as AIRFLOW_CONN_{CONN_ID} with provided values.

provide_gcp_credentials([key_file_path, key_file_dict])

Context manager that provides Google Cloud credentials for Application Default Credentials (ADC).

provide_gcp_connection([key_file_path, scopes, project_id])

Context manager that provides a temporary value of AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT connection.

provide_gcp_conn_and_credentials([key_file_path, ...])

Context manager that provides GPC connection and credentials.

get_credentials_and_project_id(*args, **kwargs)

Returns the Credentials object for Google API and the associated project_id.

Attributes

log

AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT

airflow.providers.google.cloud.utils.credentials_provider.log[source]
airflow.providers.google.cloud.utils.credentials_provider.AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT = 'AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT'[source]
airflow.providers.google.cloud.utils.credentials_provider.build_gcp_conn(key_file_path=None, scopes=None, project_id=None)[source]

Build a uri that can be used as AIRFLOW_CONN_{CONN_ID} with provided values.

Parameters
  • key_file_path (str | None) – Path to service key.

  • scopes (Sequence[str] | None) – Required OAuth scopes.

  • project_id (str | None) – The Google Cloud project id to be used for the connection.

Returns

String representing Airflow connection.

Return type

str

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_credentials(key_file_path=None, key_file_dict=None)[source]

Context manager that provides Google Cloud credentials for Application Default Credentials (ADC).

It can be used to provide credentials for external programs (e.g. gcloud) that expect authorization file in GOOGLE_APPLICATION_CREDENTIALS environment variable.

Parameters
  • key_file_path (str | None) – Path to file with Google Cloud Service Account .json file.

  • key_file_dict (dict | None) – Dictionary with credentials.

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_connection(key_file_path=None, scopes=None, project_id=None)[source]

Context manager that provides a temporary value of AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT connection.

It builds a new connection that includes path to provided service json, required scopes and project id.

Parameters
  • key_file_path (str | None) – Path to file with Google Cloud Service Account .json file.

  • scopes (Sequence | None) – OAuth scopes for the connection

  • project_id (str | None) – The id of Google Cloud project for the connection.

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_conn_and_credentials(key_file_path=None, scopes=None, project_id=None)[source]

Context manager that provides GPC connection and credentials.

It provides both:

Parameters
  • key_file_path (str | None) – Path to file with Google Cloud Service Account .json file.

  • scopes (Sequence | None) – OAuth scopes for the connection

  • project_id (str | None) – The id of Google Cloud project for the connection.

airflow.providers.google.cloud.utils.credentials_provider.get_credentials_and_project_id(*args, **kwargs)[source]

Returns the Credentials object for Google API and the associated project_id.

Was this entry helpful?