If you've recently tried to push code to a private GitHub repository using HTTPS and encountered an error like this:

fatal: HttpRequestException encountered.
An error occurred while sending the request.
Username for 'https://github.com': abcd
remote: Support for password authentication was removed on August 13, 2021.
fatal: Authentication failed for 'https://github.com/test/cr/

Don't panic — you're not alone. This blog will explain why and how to fix it using GitHub's current authentication methods.

❓ Why This Happens
Since August 13, 2021, GitHub no longer supports password-based authentication for Git operations over HTTPS.

This change was made to improve security, and now developers must authenticate using either:

🔑 Personal Access Tokens (PAT)
🛡️ SSH Keys

✅ Solution 1: Use a Personal Access Token (HTTPS)

When Git prompts for a username and password, you should:

Enter your GitHub username as usual

Enter your Personal Access Token instead of your password

🔧 Steps to Create a Token:

  1. Go to GitHub → Settings → Developer Settings → Personal Access Tokens

  2. Click “Generate new token (classic)” or “Fine-grained token”

  3. Set expiration (e.g., 30 days)

  4. Select the **repo **scope

  5. Click Generate token

  6. Copy the token *immediately *(you won't see it again)

👨‍💻 Next, push your code:

git add .
git commit -m "Your commit message"
git push origin your-branch-name

When prompted:

Username:

Password: Paste the token you generated

✅ Solution 2: Use SSH (Recommended for Long-Term)

If you regularly work with private repos, SSH is more convenient and secure.

🔧 Steps:

  1. Generate SSH Key:

ssh-keygen -t ed25519 -C "[email protected]"

  1. Add SSH Key to GitHub:

Copy the public key:

cat ~/.ssh/id_ed25519.pub

Then go to GitHub → Settings → SSH and GPG Keys
→ Click “New SSH Key”, paste the key, and save.

  1. Switch your remote URL:

git remote set-url origin [email protected]:OUP2/ernie.git

  1. Now push:

git push origin your-branch-name

🧠 Bonus: Cache Your Credentials (Optional)
To avoid typing your token repeatedly:

git config --global credential.helper cache
Or use GitHub’s credential manager for Windows/macOS.

🚀 You're Good to Go!
By replacing your GitHub password with a PAT or SSH key, you'll be compliant with GitHub’s current security policies and avoid annoying errors like HttpRequestException encountered.

Happy coding! 💻✨