Skip to main content

prefect_gcp.credentials

Module handling GCP credentials.

Classes

ClientType

GcpCredentials

Block used to manage authentication with GCP. Google authentication is handled via the google.oauth2 module or through the CLI. Specify either one of service account_file or service_account_info; if both are not specified, the client will try to detect the credentials following Google’s Application Default Credentials. See Google’s Authentication documentation for details on inference and recommended authentication patterns. Attributes:
  • service_account_file: Path to the service account JSON keyfile.
  • service_account_info: The contents of the keyfile as a dict.
Methods:

block_initialization

get_access_token

See: https://stackoverflow.com/a/69107745 Also: https://www.jhanley.com/google-cloud-creating-oauth-access-tokens-for-rest-api-calls/

get_bigquery_client

Gets an authenticated BigQuery client. Args:
  • project: Name of the project to use; overrides the base class’s project if provided.
  • location: Location to use.
Returns:
  • An authenticated BigQuery client.
Examples: Gets a GCP BigQuery client from a path.
Gets a GCP BigQuery client from a dictionary.

get_client

Helper method to dynamically get a client type. Args:
  • client_type: The name of the client to get.
  • **get_client_kwargs: Additional keyword arguments to pass to the get_*_client method.
Returns:
  • An authenticated client.
Raises:
  • ValueError: if the client is not supported.

get_cloud_storage_client

Gets an authenticated Cloud Storage client. Args:
  • project: Name of the project to use; overrides the base class’s project if provided.
Returns:
  • An authenticated Cloud Storage client.
Examples: Gets a GCP Cloud Storage client from a path.
Gets a GCP Cloud Storage client from a dictionary.

get_credentials_from_service_account

Helper method to serialize credentials by using either service_account_file or service_account_info.

get_job_service_async_client

Gets an authenticated Job Service async client for Vertex AI. Returns:
  • An authenticated Job Service async client.
Examples: Gets a GCP Job Service client from a path.
Gets a GCP Cloud Storage client from a dictionary.

get_job_service_client

Gets an authenticated Job Service client for Vertex AI. Returns:
  • An authenticated Job Service client.
Examples: Gets a GCP Job Service client from a path.
Gets a GCP Cloud Storage client from a dictionary.

get_secret_manager_client

Gets an authenticated Secret Manager Service client. Returns:
  • An authenticated Secret Manager Service client.
Examples: Gets a GCP Secret Manager client from a path.
Gets a GCP Cloud Storage client from a dictionary.