Skip to main content

prefect_bitbucket.credentials

Module to enable authenticate interactions with BitBucket.

Classes

ClientType

The client type to use.

BitBucketCredentials

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:
from prefect_bitbucket import BitBucketCredentials
bitbucket_credentials_block = BitBucketCredentials.load("BLOCK_NAME")
Methods:

format_git_credentials

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

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.