Back to Prefect

credentials

docs/integrations/prefect-bitbucket/api-ref/prefect_bitbucket-credentials.mdx

3.6.30.dev32.6 KB
Original Source

prefect_bitbucket.credentials

Module to enable authenticate interactions with BitBucket.

Classes

ClientType <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-bitbucket/prefect_bitbucket/credentials.py#L27" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

The client type to use.

BitBucketCredentials <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-bitbucket/prefect_bitbucket/credentials.py#L34" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Store BitBucket credentials to interact with private BitBucket repositories.

Attributes:

  • token: An access token to authenticate with BitBucket. This is required for accessing private repositories.
  • username: Identification name unique across entire BitBucket site.
  • password: The password to authenticate to BitBucket.
  • url: The base URL of your BitBucket instance.

Examples:

Load stored BitBucket credentials:

python
from prefect_bitbucket import BitBucketCredentials
bitbucket_credentials_block = BitBucketCredentials.load("BLOCK_NAME")

Methods:

format_git_credentials <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-bitbucket/prefect_bitbucket/credentials.py#L93" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
format_git_credentials(self, url: str) -> str

Format and return the full git URL with BitBucket credentials embedded.

BitBucket has different authentication formats:

  • BitBucket Server: username:token format required
  • BitBucket Cloud: x-token-auth:token prefix
  • Self-hosted instances: If username is provided, username:token format is used regardless of hostname (supports instances without 'bitbucketserver' in URL)

Args:

Returns:

  • Complete URL with credentials embedded

Raises:

  • ValueError: If credentials are not properly configured

get_client <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-bitbucket/prefect_bitbucket/credentials.py#L154" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
get_client(self, client_type: Union[str, ClientType], **client_kwargs) -> Union[Cloud, Bitbucket]

Get an authenticated local or cloud Bitbucket client.

Args:

  • client_type: Whether to use a local or cloud client.

Returns:

  • An authenticated Bitbucket client.