Maybe credential.helper
or the old Fine-grained Personal Access Token (FGPAT) is tricking you.
IT IS SO WEIRD AND FRUSTRATING!!!
My old FGPAT is still valid till now. I used it to clone my private repo about 1 month ago. It works fine then.
Today, I deleted the repo folder and wanna clone again, using git clone https://oauth2:$GITHUB_API_KEY@github.com/MY_USERNAME/MY_PRIVATE_REPO.git
, error:
git clone https://oauth2:$GITHUB_API_KEY@github.com/MY_USERNAME/MY_PRIVATE_REPO.git
Cloning into 'MY_PRIVATE_REPO'...
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/MY_USERNAME/MY_PRIVATE_REPO.git/'
This error made me believe that the problem is the authentication method "password authentication".
So I open the link and read, nothing helps. I googled all kinds of articles and posts to figure this out, found out some HTTPS URL formats, none of them work:
git clone https://$GITHUB_API_KEY@github.com/MY_USERNAME/MY_PRIVATE_REPO.git
git clone https://MY_USERNAME:$GITHUB_API_KEY@github.com/MY_USERNAME/MY_PRIVATE_REPO.git
git clone https://github.com/MY_USERNAME/MY_PRIVATE_REPO.git
After hours of frustration, I did sudo git config --system --unset credential.helper
, then https://oauth2:$GITHUB_API_KEY@github.com/MY_USERNAME/MY_PRIVATE_REPO.git
, still get the same error.
I created a new FGPAT, solved.
Conclusion
It seems that a new FGPAT helps, but sudo git config --system --unset credential.helper
is still worth a try.
I still can not understand why should I create a new FGPAT while the old one is still valid.