I recently tried to re-download all of the modules in my magento installation to fill in the vendor directory.

I ran

cd /path/to/magento2/root;
composer install;

It worked until it got to a module called magento/module-sales-archive (100.0.2)

Then I got this error

[Composer\Downloader\TransportException]                                                                                                        
Invalid credentials for 'https://repo.magento.com/archives/magento/module-sales-archive/magento-module-sales-archive-100.0.2.0.zip', aborting.  

This is because this module requires developer creds to download it.

The username & password in your auth.json file are incorrect.

In your Magento 2 root directory, there should be a file called auth.json (if it isn’t there, create it).

And it’s contents should look like this:

{
  "http-basic": {
    "repo.magento.com": {
      "username": "HASHED_USERNAME",
      "password": "HASHED_PASSWORD"
    }
  }
}

You need to generate a new username and PW.

Get new credentials from the Magento 2 marketplace

Go here and log in.

If you don’t have an account, create one.

Navigate to your My Account dashboard.

My Account Dropdown

Then navigate to My Access Keys in the bottom left of the dashboard.

My Account Dropdown

If you have an Access Key here, good, if not, click Generate New.

You should get a Public Key and a Private Key.

"Public Key" === username
"Private Key" === password

Take those values and plug them in to your auth.json file.

Now, re-run

composer install

From your root directory, and it should work!