How to use private Bitbucket repos in composer

In composer’s docs there’s a helpful article: Authentication for privately hosted packages and repositories

They again link to this page at Atlassian support: Use OAuth on Bitbucket Cloud

In summary:

Bitbucket

composer

Add the consumer key and secret to composer’s configuration:

composer config [--global] bitbucket-oauth.bitbucket.org [consumer-key] [consumer-secret]

In composer.json, add the repo as a repository:

"repositories": [
    ...
    ,{
        "type": "vcs",
        "url": "https://your-username@bitbucket.org/your-workspace/your-repo.git"
    }
    ...
}

That should be all! Now you can composer install and/or composer update to pull your repo.

(And if you’re balking at that comma, it’s because it makes it easier to cut/paste/move entries around without getting annoyed by missing/trailing comma errors.)