Use multiple set of credentials per repository in Composer

In this post, we explain how to use different credentials for the same repository in composer in magento2. Subscribe to Bnethos for all the Magento2 problems and customizations.


Composer is a popular package manager for PHP. Many platforms use composer, including Magento 2. Within Magento 2, Composer allows managing libraries, Magento and third-party modules. Composer installs, updates and removes modules once a specific command has been run. It scans the composer.json file and manages modules according to the set dependencies.

Sometimes we have a different account for different module which are used in same project, At that time you may wonder how to add different credentials for same repository. We explained the problem in the below steps.

In this post, we are explaining the multiple set of credentials per repository using amasty repo.

To download and install Magento modules, the vendor’s repository is required. The repository is a Composer path to the storage with extensions. The below command will add a repository in the root composer.json

The result will be like below in the root composer.json file under “repositories”

To access the purchased modules, access keys are required. The customer will be asked for a login (Public Key) and password (Private Key) when trying to install the package from the Composer repository for the first time, It will be save in root auth.json.

For example command:

The result will be like below in the root auth.json :

Now we came to the actual problem, if we bought some modules using different account in vendor, they provide different credentials, at that time you may wonder how to add it in auth.json. We’ll explain below.

In the above steps, we added the Repo in the composer.json, Now we need to add another repository like below.

Based on the repo url, you can configure the authorization credentials in auth.json using the below commands or you can add manually.

The result will be like below in the auth.json:

Unfortunately only a few vendors have multiple URL aliases, so you get the same problem as soon as you’re dealing with multiple client accounts. Amasty, Mageworx and Xtento do provide this, but even some of the big players do not 

That’s all now you can able to download different module using different credentials with same repo.

If you need more help regarding this post, feel free to ask in the Comments section below.

I would be happy to solve your queries.

6 thoughts on “Use multiple set of credentials per repository in Composer”

Leave a Comment