Authentication
The Bitbucket CLI uses API Tokens for authentication. This is a secure way to grant CLI access without exposing your main account password.
Create an API Token
Section titled “Create an API Token”- Log in to Bitbucket
- Go to Personal settings (click your avatar in the bottom left)
- Navigate to API tokens under “Access management”
- Click Create API token
- Give it a descriptive name (e.g., “Bitbucket CLI”)
- Select the required scopes:
- Account: Read
- Repositories: Read, Write, Admin (depending on your needs)
- Pull requests: Read, Write
- Click Create
- Copy the generated token - you won’t be able to see it again!
bb auth login -u your-username -p your-api-tokenUsing Environment Variables
Section titled “Using Environment Variables”You can also set credentials via environment variables, which is especially useful for CI/CD pipelines:
export BB_USERNAME=your-usernameexport BB_API_TOKEN=your-api-tokenbb auth loginSee Environment Variables Reference for more details on using environment variables in scripts and CI/CD.
Check Auth Status
Section titled “Check Auth Status”bb auth statusThis shows your current authentication status and account information.
Logout
Section titled “Logout”bb auth logoutThis removes only stored credentials (username and apiToken) from your system and preserves non-auth CLI settings.
Configuration Storage
Section titled “Configuration Storage”Credentials are stored in:
- Linux/macOS:
~/.config/bb/config.json - Windows:
%APPDATA%\bb\config.json
See Configuration File Reference for details on the config file format.
Next Steps
Section titled “Next Steps”- Quick Start Guide - Get up and running in 60 seconds
- Repository Context - How the CLI detects your workspace/repo
- Troubleshooting - Common authentication issues and solutions