Your Magento authentication keys are invalid

When you are installing Magento from scratch using the composer method, it might be the case that it's not asking you Magento authentication public and private keys. In that case, you can simply use the below command from your terminal.

php composer.phar global config http-basic.repo.magento.com <Public Key> <Private Key>

After that you can continue with Magento 2 installation process without the authentication keys are invalid error.