# How to authenticate to GitHub using username and password

> Learn how to authenticate to GitHub when username and password no longer work, by creating a personal access token with repo scope to use as the password.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-11-29 | Topics: [Git](https://flaviocopes.com/tags/git/) | Canonical: https://flaviocopes.com/github-auth-username-password/

I was setting up a new editor and I was trying the [GitHub](https://flaviocopes.com/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**:

![GitHub settings sidebar with Developer settings option highlighted](https://flaviocopes.com/images/github-auth-username-password/Screen_Shot_2021-11-28_at_11.02.41.png)

Clicked **Personal access tokens**:

![GitHub Developer settings page showing Personal access tokens section with Generate new token button](https://flaviocopes.com/images/github-auth-username-password/Screen_Shot_2021-11-28_at_11.03.51.png)

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:

![New personal access token form with note field, expiration dropdown, and scopes list including repo scope](https://flaviocopes.com/images/github-auth-username-password/Screen_Shot_2021-11-28_at_11.04.12.png)

![Token expiration set to No expiration with repo scope checked and enabled for full control of private repositories](https://flaviocopes.com/images/github-auth-username-password/Screen_Shot_2021-11-28_at_11.04.51.png)

Save and you'll be able to see the token.

![Personal access tokens list showing the newly created Nova editor token with repo scope and no expiration date](https://flaviocopes.com/images/github-auth-username-password/Screen_Shot_2021-11-28_at_11.09.05.png)

Now enter this token as the password in the username/password dialog window.

You're set.
