Skip to content

Auth Commands

Manage authentication with Bitbucket.

bb auth login

Authenticate with Bitbucket using an API token.

Terminal window
bb auth login [options]

Options

OptionDescription
-u, --username <username>Bitbucket username
-p, --password <password>Bitbucket API token
--jsonOutput as JSON

Examples

Terminal window
# Login with credentials via command line
bb auth login -u myuser -p your-api-token
# Login using environment variables
export BB_USERNAME=myuser
export BB_API_TOKEN=your-api-token
bb auth login

How It Works

  1. You provide your Bitbucket username and API token
  2. The CLI stores the credentials securely in your config file
  3. The CLI verifies the credentials by fetching your user information
  4. If verification fails, credentials are not saved

Required Scopes

Your API token needs these scopes:

  • Account: Read (to verify your identity)
  • Repositories: Read, Write (depending on operations you’ll perform)
  • Pull requests: Read, Write (for PR operations)

See the Authentication guide for detailed setup instructions.


bb auth logout

Log out of Bitbucket and remove stored credentials.

Terminal window
bb auth logout [options]

Options

OptionDescription
--jsonOutput as JSON

Examples

Terminal window
bb auth logout

What Gets Removed

This command removes your stored credentials (username and apiToken) from the config file. Other settings like workspace and repo are preserved.


bb auth status

Show current authentication status and account information.

Terminal window
bb auth status [options]

Options

OptionDescription
--jsonOutput as JSON

Examples

Terminal window
# Check authentication status
bb auth status
# Get status as JSON
bb auth status --json

Output

When authenticated:

✓ Logged in to Bitbucket
Username: myuser
Display name: My Name
Account ID: 123456789

When not authenticated:

ℹ Not logged in
Run bb auth login to authenticate.

bb auth token

Print the current access token (base64 encoded credentials).

Terminal window
bb auth token [options]

Options

OptionDescription
--jsonOutput as JSON

Examples

Terminal window
# Print the token
bb auth token
# Get token as JSON
bb auth token --json

Use Cases

This is useful for:

  • Debugging authentication issues
  • Using the token with other tools or scripts
  • Verifying token format