Question

I want to setup new extension with composer on magento2 and I get this error:

[Composer\Downloader\TransportException]
Invalid credentials for 'https://repo.magento.com/packages.json', aborting.

I use public key and private key as user and password ( get key from marketplace.magento.com )

I use this comment for install new extension:

composer require mageplaza/composer require mageplaza/magento-2-seo-extension
Was it helpful?

Solution

I want you to try two things:

  1. Do you have more than one pair of public and private key enabled? If yes then try by enabling just one and disable all else.
  2. Create auth.json:

    To create auth.json:

    • Log in to your Magento server as, or switch to, the Magento file system owner.
    • Edit or create auth.json in the user’s home directory.

      The following example shows how to add repo.magento.com authentication to an existing file:

{
   "github-oauth": {
     "github.com": "<your github oauth id>"
   },
   "http-basic": {
      "repo.magento.com": {
         "username": "<public key>",
         "password": "<private key>"
      }
   }
}

Source: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/dev_install.html#create-authjson

OTHER TIPS

TLDR; => enter public key as Username and private key as Password

I get here with similar problem / refresh topic. I want to try install magento first time. Following this start guide

Using this composer command give me auth error:

create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>

enter image description here

I registered to magento and i generate Api keys. But composer command was prompt for username so i try my user name which Magento generate for me, i tried my username and this public key and all this attempts ends with auth error.

Finnally i tried paste public key as Username and private key as Password and it works like a charm : )

enter image description here

Hope i help somebody

If someone still has trouble with getting magento 2 through composer because of authentication keys issue as given below, then make sure to update your auth.json with your Magento Authentication Keys (generated from marketplace.magento.com) inside your COMPOSER_HOME directory and then exit from your terminal / bash / shell and reopen it and try composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2/ command again to get Magento.

Detailed step by step instructions are given below:

Generate Authentication Keys inside your Magento Makeplace Account

https://marketplace.magento.com/customer/accessKeys/

Find your local machine composer home directory by typing the command below. It shows your composer path.

composer config --list --global | grep 'home'

In Windows 10 its like

C:/Users/youruser/AppData/Roaming/Composer

Open the auth.json inside the Composer Home directory (in a text-editor)

Update the file with your keys like given below

{
    "bitbucket-oauth": {},
    "github-oauth": {},
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {
        "repo.magento.com": {
            "username": "<your_public_key>",
            "password": "<your_private_key>"
        }
    },
    "bearer": {}
}

Exit the bash / shell / terminal and reopen it again and try the composer command to get the Magento package now. It will work.

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <your_magento2_install_dir>/

BTW my Composer version is 2.x. and am on Windows 10

$ composer --version
Composer version 2.0.8 2020-12-03 17:20:38

Hope this Helps !

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top