How to use private Bitbucket repos in composer

July 5, 2024 (11d ago)


  1. At Bitbucket, click on your avatar in the bottom left corner and choose a workspace.

  2. In the left menu, click Settings icon and then choose Apps and featuresOAuth consumers and click the button Add consumer.

  3. Fill in the name, callback URL with, check This is a private consumer and under Permissions select ProjectsRead.

  4. Click Save.

  5. Click the consumer name to expand the entry and copy Key and Secret.

Adding to composer

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

$ composer config --global [consumer-key] [consumer-secret]

You can list your composer's configuration:

$ composer global config --list

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

"repositories": [
        "type": "vcs",
        "url": ""

Install the package

That's it, now you can composer require vendor/package-name to pull your repo.