// Bitbucket Authentication
All Bitbucket authentication methods explained. App Passwords, OAuth 2.0, SSH keys, and Access Tokens — with curl command builder for the REST API.
App Passwords
Token scoped to specific permissions. Use as password in HTTP Basic auth or Git prompts. Supports 2FA accounts. Create at Account Settings → App Passwords.
OAuth 2.0
For web apps acting on behalf of users. Authorization Code flow for user-facing apps. Client Credentials for server-to-server. Tokens expire and must be refreshed.
SSH Keys
Add public key to Bitbucket account. Clone/push with git@bitbucket.org:workspace/repo.git — no password prompts. Best for interactive development.
Repository Access Tokens
Scoped to a single repository. Ideal for CI/CD pipelines and automation. Not tied to a user account — survives team member changes.
Password Authentication
Account password auth was deprecated in March 2022. No longer supported for Git or API. Use App Passwords instead — they provide the same access with better security.
Creating a Bitbucket App Password (step by step)
Go to bitbucket.org → click your avatar → Account Settings → App Passwords → Create app password. Give it a label (e.g., "CI Pipeline" or "Local Dev"). Select the permissions you need: Repositories (Read/Write), Pull Requests (Read/Write), Pipelines (Read/Write/Edit). Click Create. Copy the generated token immediately — it is only shown once. Use it as the password in HTTP Basic auth or Git prompts with your Bitbucket username.
Repository Access Tokens for CI/CD
Go to your repository → Repository Settings → Access Tokens → Create repository access token. Choose scopes: read (clone/fetch), write (push). The token is a Bearer token — include it in the Authorization header: Authorization: Bearer TOKEN. For Git clone over HTTPS: git clone https://x-token-auth:TOKEN@bitbucket.org/workspace/repo.git. Repository Access Tokens are not tied to a user account — they won't break if a team member leaves.
Authenticating in Bitbucket Pipelines
Within Bitbucket Pipelines, the BITBUCKET_CLONE_DIR, BITBUCKET_WORKSPACE, and BITBUCKET_REPO_SLUG variables are available automatically. For API access from pipelines, create a Repository Access Token and store it as a secured pipeline variable. Access it in your pipeline YAML as $REPO_TOKEN. Never hardcode tokens in bitbucket-pipelines.yml.
bitbucket.org → Account Settings → App Passwords → Create app password. Choose a label and select the needed permissions. Use it as the password value in HTTP Basic auth or when Git prompts for credentials. It shows only once after creation — copy it immediately. App Passwords support 2FA accounts.git clone https://x-token-auth:$TOKEN@bitbucket.org/workspace/repo.git. For API calls: curl -H "Authorization: Bearer $TOKEN" https://api.bitbucket.org/2.0/.... Never commit tokens to your repository or bitbucket-pipelines.yml.