Authenticating with GitHub via a Personal Access Token

Tom Szpytman
Feb 19 · 1 min read

A couple of blog posts ago I wrote about how you could use a GitHub repository to act as an NPM package. I went on to explain how you could configure your local git installation to authenticate with GitHub (in the event that your package is hosted in a private GitHub repository). GitHub has now deprecated the authentication method that I described, so in this post I’d like to share an updated set of instructions.

1. In a terminal, type python to open up the python interpreter.
2. In the python interpreter, enter the following:

import base64

replacing YOUR_GITHUB_USERNAME with your GitHub username, and, YOUR_GITHUB_TOKEN with the GitHub personal access token that you created last time.

3. Copy the output of the function in Step 2.
4. Open up ~/.gitconfig in your favourite editor.
5. Add the following to the end of the file:

[http ""]
extraheader = Authorization: Basic VALUE_COPIED_IN_STEP_3

replacing YOUR_GITHUB_USERNAME with your GitHub username, YOUR_GITHUB_REPO_NAME with your repository name and VALUE_COPIED_IN_STEP_3 with the value you copied in step 3.

Full-stack Software Engineer.

More From Medium

Also tagged Typescript

Also tagged Git

Also tagged Git

Git Branching

Apr 8 · 5 min read


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade