How to authenticate to GitHub using username and password
I was setting up a new editor and I was trying the GitHub push workflow.
I committed my changes, pressed “Push” and I got a dialog window to enter my GitHub username and password.
On GitHub I have 2FA set up, so you can’t just login using those credentials.
What I had to do was create a personal access token that’s tied to the app, with the permission needed.
So I went to the GitHub settings, located Developer Settings:
Clicked Personal access tokens:
Now add a name so you’ll remember what this token is for, set the expiration to “No expiration” and enable the repo
scope. That’s the only one you need:
Save and you’ll be able to see the token.
Now enter this token as the password in the username/password dialog window.
You’re set.
→ I wrote 17 books to help you become a better developer:
- C Handbook
- Command Line Handbook
- CSS Handbook
- Express Handbook
- Git Cheat Sheet
- Go Handbook
- HTML Handbook
- JS Handbook
- Laravel Handbook
- Next.js Handbook
- Node.js Handbook
- PHP Handbook
- Python Handbook
- React Handbook
- SQL Handbook
- Svelte Handbook
- Swift Handbook
Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025