GitHub
gitgithubGuideBeginner
GitHub Personal Access Tokens (PAT)
Understanding Fine-Grained Personal Access Tokens: HTTPS authentication, token scopes, expiration policies, and automated script access.
Verified: 2026-09-30
Platforms:
all
#github#pat#tokens#authentication#security
GitHub Personal Access Tokens (PAT)
GitHub deprecated account password authentication for Git operations over HTTPS in 2021. Today, developers connecting via HTTPS or accessing GitHub REST/GraphQL APIs must authenticate using a Personal Access Token (PAT).
1. Fine-Grained vs. Classic Tokens
| Token Type | Scope Granularity | Expiration | Recommended? |
|---|---|---|---|
| Fine-Grained Tokens | Restricted to specific repositories with exact read/write permissions per resource (e.g. Issues: Read-Only, Contents: Read & Write). | Mandatory (max 1 year) | ✅ Yes (Principle of Least Privilege) |
| Classic Tokens | Broad account-wide permissions (repo scope grants full read/write to all repositories you own). | Optional expiration | ❌ Deprecated for general daily use |
2. Generating a Fine-Grained Token
- Go to Settings → Developer Settings → Personal Access Tokens → Fine-grained tokens.
- Click Generate new token.
- Set a descriptive name and expiration period (e.g. 90 days).
- Under Repository access, select Only select repositories.
- Under Permissions, grant only the required permissions (e.g.
Contents: Read and write). - Copy the token string (
github_pat_...) and store it securely in a password manager.
3. Best Practices
- Never commit tokens into code: Tokens pushed to public repositories will be immediately revoked by GitHub Secret Scanning.
- Set short expiration dates: Rotate tokens every 90 days.
Related Topics
GitHub SSH Key Authentication Setup
Setting up secure passwordless SSH keys with GitHub: generating Ed25519 keypairs, ssh-agent configuration, and adding keys to GitHub settings.
GitHub Issues & Project Tracking
Managing project tasks with GitHub Issues: bug reports, feature requests, issue templates, labels, milestones, and closing issues via commits.