55

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?

  • 11
    @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. – Alan Storm Nov 20 '15 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 Nov 20 '15 at 22:54
  • I'll leave it to OP to close the question. Docs were updated after the fact. – benmarks Nov 21 '15 at 3:36
  • 7
    @Flyingmana seriously if we are going to close every question because somebody did not read the documentation.. then what is a purpose of stackexchange – Pawel Dubiel Nov 21 '15 at 21:17
  • 1
    What's the deal anyway with this login? Do they want to collect user accounts? I don't get it. – tester Dec 8 '15 at 7:02
68

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

  • 14
    Or enter your public key as the username and private key as the password at the prompts. – Alan Storm Nov 20 '15 at 18:38
  • 2
    the file is in ~/.composer/auth.json and in magento root – Claudiu Creanga Jan 29 '16 at 16:02
  • You must generate keys from Magento Marketplace see devdocs.magento.com/guides/v2.0/install-gde/prereq/… – himansu Dec 8 '16 at 17:40
  • 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 Dec 19 '16 at 12:26
  • Whenever I try to generate a new key on the site and enter in a name, the modal goes away and nothing happens. – Metropolis Nov 30 '17 at 21:14
27

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>

  • Thanks! I'll probably add that to the documentation, which is recently updated: bit.ly/1SMMh9p – Steve Johnson Nov 20 '15 at 19:27
10

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.

9

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.

  • Where i can i add this : composer.phar config http-basic.repo.magento.com <public_key> <private_key> – Gem May 2 '18 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 May 2 '18 at 14:14
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! :)

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 {}

1

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

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
  • yes, its clear instruction – matinict Sep 17 '18 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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