If you are unable to install Magento 2 from composer due to this exception, check the solution here.

How to solve Magento 2 composer installation error: Invalid credentials for 'https://repo.magento.com/packages.json'

For newbie developers in Magento, installation can be really a headache because magento forces developers to have a Magento account, thing that is usually not a thing on open source developers that love to simply clone Git repositories, modify them and that's it. In this short article, we will explain you how to solve this error during the installation of Magento 2 through composer.

1. Create a developer account for Magento

As first step, you will need to have an account in the Magento Developer portal, you can create it here. On the website, click on Create Account, fill the form and that's it:

Create account or just sign in

If you already have an account or you've just created it, proceed with the next step.

This is NOT the account that you will use in the terminal to allow the download of Magento through composer.

2. Create access key

To download Magento in composer you will need a credential, an username and a password. This credential will be composed by random strings, that is generated by an Access Key. You can create an Access Key on the Magento Developer Portal through the account information:

Magento Account Information

Then on the left side tab, click on Access Keys:

Access Key Magento 2, install through composer

In this page, click on Create New Access Key, provide a custom name and that's everything. The created entry will contain in the Access Keys column 2 registers, namely

  • Public: use this as Username in the composer prompt.
  • Private: use this as Password in the composer prompt.

After using the mentioned values as credentials, you will be able to install Magento 2 without any issue through composer.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors