airflow.providers.google.cloud.utils.credentials_provider

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

Module Contents

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: Optional[str] = None, scopes: Optional[Sequence[str]] = None, project_id: Optional[str] = None)str[source]
Builds a uri that can be used as :envvar:`AIRFLOW_CONN_{CONN_ID}` with provided service key,
scopes and project id.
Parameters
  • key_file_path (Optional[str]) -- Path to service key.

  • scopes (Optional[List[str]]) -- Required OAuth scopes.

  • project_id (Optional[str]) -- The Google Cloud project id to be used for the connection.

Returns

String representing Airflow connection.

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_credentials(key_file_path: Optional[str] = None, key_file_dict: Optional[Dict] = None)[source]
Context manager that provides a Google Cloud credentials for application supporting `Application
Default Credentials (ADC) strategy <https://cloud.google.com/docs/authentication/production>`__.

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) -- Path to file with Google Cloud Service Account .json file.

  • key_file_dict (Dict) -- Dictionary with credentials.

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_connection(key_file_path: Optional[str] = None, scopes: Optional[Sequence] = None, project_id: Optional[str] = None) → Generator[source]
Context manager that provides a temporary value of :envvar:`AIRFLOW_CONN_GOOGLE_CLOUD_DEFAULT`
connection. It build a new connection that includes path to provided service json,
required scopes and project id.
Parameters
  • key_file_path (str) -- Path to file with Google Cloud Service Account .json file.

  • scopes (Sequence) -- OAuth scopes for the connection

  • project_id (str) -- The id of Google Cloud project for the connection.

airflow.providers.google.cloud.utils.credentials_provider.provide_gcp_conn_and_credentials(key_file_path: Optional[str] = None, scopes: Optional[Sequence] = None, project_id: Optional[str] = None) → Generator[source]
Context manager that provides both:
Parameters
  • key_file_path (str) -- Path to file with Google Cloud Service Account .json file.

  • scopes (Sequence) -- OAuth scopes for the connection

  • project_id (str) -- The id of Google Cloud project for the connection.

airflow.providers.google.cloud.utils.credentials_provider.get_credentials_and_project_id(*args, **kwargs) → Tuple[google.auth.credentials.Credentials, str][source]
Returns the Credentials object for Google API and the associated project_id.

Was this entry helpful?