Getting a GitHub Personal Access Token - A Complete Guide

May 08, 2026

If you’re building applications that interact with GitHub—whether you’re automating workflows, syncing repositories, or connecting GitHub with tools like Sequels.diy you’ll need a secure way to authenticate. That’s where Personal Access Tokens come in. They’re the recommended way to access GitHub programmatically, replacing the need to expose your main password. In this guide, we’ll walk you through creating, configuring, and securely managing your tokens so you can start automating with confidence.

What is a Personal Access Token?

A Personal Access Token (PAT) is basically like a password, but specifically for accessing GitHub through code or scripts. Instead of using your actual GitHub password, you create a token that has specific permissions. This is way safer because if something goes wrong, you can just delete the token without changing your whole password.

Why Do You Need It?

You need a Personal Access Token for a bunch of different stuff:

Basically, if you want to automate anything with GitHub, you’ll need a Personal Access Token!

Step-by-Step Guide to Create One

Step 1: Go to GitHub Settings

First, log in to your GitHub account. Then:

Step 2: Navigate to Developer Settings

On the left sidebar, scroll down and click on Developer settings (it’s at the very bottom of the list).

Step 3: Go to Personal Access Tokens

In the Developer settings page, on the left sidebar, you’ll see Personal access tokens. Click on it and select Tokens (classic).

Step 4: Generate a New Token

Click the Generate new token button and select Generate new token (classic).

Step 5: Configure Your Token

Now comes the important part - setting up what your token can do.

Give it a name - Something descriptive like “GitHub Automation” or “My App Integration”

Set an expiration - You can choose how long the token is valid. I usually pick 30 or 90 days just to be safe. You can always create a new one later.

Select scopes - This is where you choose what permissions the token has. Here’s what you probably need depending on what you want to do:

For Repository Notifications:

For Repository Events & Commits:

For Releases:

For Issues & Pull Requests:

For Gists:

For User Activity (Public):

Pro tip: Start with minimal permissions. If you find out later that you need more, you can always create another token with more permissions.

Step 6: Generate and Copy

Once you’ve selected your scopes, click the green Generate token button at the bottom.

⚠️ IMPORTANT: GitHub will show you the token only once! Copy it and save it somewhere safe (like a password manager or a secure file). Once you leave this page, you won’t be able to see it again. If you lose it, you’ll have to generate a new one.

Using Your Token

When you need to use the token in your code or scripts, it usually looks something like this:

ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Command Line Example:

git clone https://github.com/username/repo.git
# When prompted for password, use your token instead

API Example:

curl -H "Authorization: token ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  https://api.github.com/user

Security Tips

  1. Never share your token - Treat it like a password
  2. Don’t commit it to GitHub - Don’t accidentally push it to a public repo
  3. Use environment variables - Store it in a .env file (and add .env to .gitignore)
  4. Delete old tokens - If you’re not using it anymore, delete it
  5. Check regularly - Go back to your token settings and see which tokens are active

Revoking a Token

If you think your token got compromised or you just don’t need it anymore:

  1. Go to Settings → Developer settings → Personal access tokens
  2. Find the token you want to delete
  3. Click Delete

That’s it! The token is gone and can’t be used anymore.

Troubleshooting

“Invalid token” error?

“Insufficient permissions” error?

Can’t find Personal Access Tokens in settings?

Final Thoughts

Honestly, Personal Access Tokens seem scary at first, but they’re super useful once you get the hang of them. Just remember to keep them safe and delete them when you don’t need them anymore. Good luck with your GitHub automation! 🚀


Have questions? Drop them in the comments! And if this helped you, feel free to share it with other people learning GitHub API stuff.