How to use private Bitbucket repos in composer

If you want to use a private Bitbucket repo in composer, you need to create a OAuth consumer key/secret pair in Bitbucket and configure composer to use that when fetching your repo.

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 featuresOAuth consumers and click the button Add consumer.
  • Fill in the name (and optionally a description), and under Permissions select ProjectsRead.
  • 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] [consumer-key] [consumer-secret]

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

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

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.)