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:
At Bitbucket, click on your avatar in the bottom left corner and choose a workspace.
In the left menu, click Settings and then choose Apps and features → OAuth consumers and click the button Add consumer.
Fill in the name (and optionally a description), and under Permissions select Projects → Read.
Click Save.
Click the consumer name to expand the entry and copy Key and Secret.
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.)