Sometimes, when trying to install a Magento 2 module via Composer you get the error: Invalid credential
The username and password required are not the ones you use to login in magentocommerce.com You have to use the keys generated in your Magento account.
Go to your Account settings then click on the Connect tab. On the left you will find the button Secure keys which opens the secure keys generation page to the right. Press Generate new to get the Public key and Private key.
In the CLI use the Public key as the username
and the Private key as the password
Afterwards you have the option for the keys to be saved by composer so you don't have to go through all these steps in the future.