If someone still has trouble with getting magento 2 through composer because of authentication keys issue as given below, then make sure to update your
auth.json with your Magento Authentication Keys (generated from marketplace.magento.com) inside your COMPOSER_HOME directory and then exit from your terminal / bash / shell and reopen it and try
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2/ command again to get Magento.
Detailed step by step instructions are given below:
Generate Authentication Keys inside your Magento Makeplace Account
Find your local machine composer home directory by typing the command below. It shows your composer path.
composer config --list --global | grep 'home'
In Windows 10 its like
Open the auth.json inside the Composer Home directory (in a text-editor)
Update the file with your keys like given below
Exit the bash / shell / terminal and reopen it again and try the composer command to get the Magento package now. It will work.
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <your_magento2_install_dir>/
BTW my Composer version is 2.x. and am on Windows 10
$ composer --version
Composer version 2.0.8 2020-12-03 17:20:38
Hope this Helps !