71

I've generated a new Magento Connect key per the developer documentation instructions. How am I supposed to use this key? i.e., if I try getting info, I see the following.

$ composer info magento/sample-data
    Authentication required (repo.magento.com):
      Username: 

If I try following the new installation instructions, I get the same thing.

$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
    Authentication required (repo.magento.com):
      Username: 

Is the key my password? If so, what's the username? If the key's a true key (i.e. no usename/password needed) where do I configure the key?

6
  • 15
    @Flyingmana The author did read through the documentation, and the documentation made no mention that a Magento key pair corresponds to composer username/password. Perhaps that's obvious to some, but it's not obvious to all. Commented Nov 20, 2015 at 18:59
  • 1
    The documentation changed shortly after the GA. Out of the gate it required the account username/password (which I'm not sure work anymore), but then they updated it. Yeah…huge oversight, but at least it's using generated tokens now. :)
    – davidalger
    Commented Nov 20, 2015 at 22:54
  • I'll leave it to OP to close the question. Docs were updated after the fact.
    – benmarks
    Commented Nov 21, 2015 at 3:36
  • 9
    @Flyingmana seriously if we are going to close every question because somebody did not read the documentation.. then what is a purpose of stackexchange Commented Nov 21, 2015 at 21:17
  • 2
    What's the deal anyway with this login? Do they want to collect user accounts? I don't get it.
    – tester
    Commented Dec 8, 2015 at 7:02

8 Answers 8

96

Magento comes with a sample file in your root as auth.json.sample you need to copy it to auth.json

It contains 2 key sets: 1 for Github and 1 for the Magento Repo

enter image description here

Enter the following data to your auth.json file to login. Please use the Public Key and the Private Key

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

enter image description here

nb. the auth file can also be found in your user root directory and hence be used elsewhere ~/.composer/auth.json

9
  • 18
    Or enter your public key as the username and private key as the password at the prompts. Commented Nov 20, 2015 at 18:38
  • 3
    the file is in ~/.composer/auth.json and in magento root Commented Jan 29, 2016 at 16:02
  • You must generate keys from Magento Marketplace see devdocs.magento.com/guides/v2.0/install-gde/prereq/…
    – himansu
    Commented Dec 8, 2016 at 17:40
  • 2
    why is username called public key or vice versa? The prompt should ask for public key etc! Why create the confusion with different labels?
    – Jon
    Commented Dec 19, 2016 at 12:26
  • 1
    Whenever I try to generate a new key on the site and enter in a name, the modal goes away and nothing happens.
    – Metropolis
    Commented Nov 30, 2017 at 21:14
36

Previous example is correct. In addition... it's also possible by composer's config command.

composer.phar global config http-basic.repo.magento.com <public_key> <private_key>

3
  • Thanks! I'll probably add that to the documentation, which is recently updated: bit.ly/1SMMh9p Commented Nov 20, 2015 at 19:27
  • 2
    I think composer.phar may be deprecated. composer config --global http-basic.repo.magento.com <public_key> <private_key> will work.
    – Antonio
    Commented Feb 7, 2020 at 19:27
  • Thanks for this. This is what i am looking for. Commented Sep 1, 2021 at 7:23
16

Login in magento using your credentials. Then follow the navigation

1.My Account

2.Marketplace

3.My Access Key

4.Magento2

Public Key: xxxxx

Private Key:xxxxx

Public Key used as user name and Private Key used as password.

14

Previous examples are correct. In addition it is also possible by composer's config command.

Inside the Magento project directory execute the following Composer command:

$ composer config http-basic.repo.magento.com <public_key> <private_key>

Just replace the placeholders with the actual values (public_key will become the username and private_key the password in HTTP authentication with repo.magento.com).

The auth settings can be tested by using fetching latest version with a faked update:

$ composer update --dry-run

This will give an error message like:

Invalid credentials for 'https://repo.magento.com/packages.json', aborting.

if something is wrong with the credentials.

I can strongly suggest to manage credentials inside the project folder as my answer suggests. I also would not edit the auth.json by hand but just with the composer command as it is less error-prone.

2
  • Where i can i add this : composer.phar config http-basic.repo.magento.com <public_key> <private_key>
    – Gem
    Commented May 2, 2018 at 9:30
  • @Rathinam You don't add it, you execute it. the command is "composer", see composer documentation on how to use that utility for all the details: getcomposer.org
    – hakre
    Commented May 2, 2018 at 14:14
4

To Find Authentication username & password . Just follow below steps

Authentication required (repo.magento.com):
      Username: 
  1. open https://marketplace.magento.com/customer/account/ & Login
  2. Click on 'My Profile'
  3. click 'Marketplace' Then Click 'My Access' link
  4. On My Access Keys page, click on 'Magento 2' tab
  5. click on 'Create A New Access Key' button, you will get two keys Public and Private: Public Key is your username; Private Key is your password
  6. Copy key
1
  • yes, its clear instruction
    – matinict
    Commented Sep 17, 2018 at 4:15
3

All answers are good just to compile possible scenarios on a single place.

Magento announced a new way to communicate to marketplace via compsoer, when you run composer install in the root directory of Magento it will prompt for username and password, remember this is not the Magento username and password it is Public and Private key of Magento Marketplace.

Login to Magento Marketplace.

Go to My Account.

Under My Products click Access Keys.

Select ver of Magento (1 or 2).

Click Create A New Access Key, in popup box name your key.

Clicking on Ok will generate pair of keys, Public and Private.

Now in Magento root or open ~/.composer/auth.json and put following lines

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

You are good to go. Remember auth.json file contains standard json if you see any error just make sure that your auth file contains valid json, you can validate your json on JsonLint

If you don't want to add this information in above mentioned file (although it is handy, you don't need to open Marketplace dashboard repeatedly), then on run time just enter your Public key as username and Private key as your password, if you didn't add pair of keys in auth.json in previous step, don't worry Magento will ask you here whether to store this information or not, the choice is yours! :)

2

If you are trying from the command line interface :

Authentication required (repo.magento.com):
Username: "Your public key"
Password: "Your private key"

Remember here Username means "public key" and password means "private key"
Keep developing...

1

If this code will give error like auth.json does not contain valid JSON Parse error on line 1:

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

Than it will be like below:

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

Here You should Wrap your auth.json File with extra {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.