When a string starting with gh turns up in a log, a paste site or a secret scanning alert, a responder needs to know within seconds what it is, whose it is and how to kill it. GitHub issues six prefixed token types plus several unprefixed credentials, and each has a different owner, lifetime and revocation route. This reference maps every documented prefix to its token type, issuer, scope model and lifetime, then gives the revocation path for each and the detection settings that catch leaks early. It is written for platform engineers, secret scanning teams and incident responders working on GitHub.com and GitHub Enterprise Cloud.
This is an independent guide from NHI Mgmt Group, based on GitHub's public documentation as of November 2026. It is not sponsored or reviewed by GitHub. Product features change, so confirm settings against GitHub's current documentation.
Key takeaways
- The prefix tells you the type. ghp_ is a classic personal access token, github_pat_ a fine-grained one, gho_ an OAuth app token, ghu_ a GitHub App user token, ghs_ a GitHub App installation token and ghr_ a GitHub App refresh token.
- Lifetime varies from one hour to forever. Installation tokens last 1 hour and app user tokens 8 hours by default, while classic PATs and OAuth tokens are long-lived until someone revokes them.
- Revocation depends on who owns the token. The owner can delete a PAT, an app owner can revoke an installation token, organisation owners can restrict or revoke, and anyone holding a leaked value can submit it to the credential revocation API.
- Not every credential has a prefix. SSH keys, deploy keys and the Actions GITHUB_TOKEN have no GitHub prefix, so they need their own inventory and revocation steps.
- Formats change, so match on prefix, not length. Since 27 April 2026 GitHub has been rolling out a longer stateless format for ghs_ installation tokens; detection rules that assume a fixed 40-character token will miss them.
GitHub token types at a glance
GitHub's credential types reference groups programmatic credentials by what they act as. Personal access tokens act as a user. OAuth app tokens and GitHub App user tokens act as a user on behalf of an application. Installation tokens act as the GitHub App itself within one installation. Choosing between these for a new integration is covered in GitHub Apps vs Personal Access Tokens vs OAuth Apps; this page is the lookup for identifying and handling a token you already have in front of you.
| Credential | Prefix | Acts as | Associated with | Lifespan (GitHub docs) |
|---|---|---|---|---|
| Personal access token (classic) | ghp_ | The user, limited by OAuth scopes | User account | Long-lived |
| Fine-grained personal access token | github_pat_ | The user, limited to one resource owner, selected repositories and permissions | User account | Configurable, up to 1 year, or no expiration |
| OAuth app access token | gho_ | The user, through an OAuth app with scopes | User account | Long-lived |
| GitHub App user access token | ghu_ | The user, limited by the app's permissions and the user's access | User account | 8 hours by default |
| GitHub App installation access token | ghs_ | The app installation | App installation | 1 hour |
| GitHub App refresh token | ghr_ | Used only to obtain a new ghu_ token | User account | 6 months |
| User SSH key | None | The user for Git operations | User account | Long-lived |
| Deploy key | None | One repository | Repository | Long-lived |
| GITHUB_TOKEN (Actions) | None documented | The workflow run, within repository scope | Workflow run | Job duration |
Two rules from the PAT documentation shape triage. Both PAT types are tied to the user who generated them and become inactive if the user loses access to the resource. A token's scopes or permissions never exceed the user's own access: a classic PAT with admin:org gives no administrative access if its owner is not an organisation owner. So the blast radius of any user-bound token is the intersection of its scopes and its owner's current rights.
Token prefixes and formats
GitHub moved to prefixed tokens in 2021. The engineering post that introduced them explains the design: a three-letter prefix of gh plus a letter for the token type, an underscore separator, a Base62 body, and a 32-bit CRC32 checksum in the last six characters. The underscore is not a Base64 character, which makes accidental matches against random encoded data unlikely, and the checksum lets a scanner reject strings that merely look like tokens without calling GitHub. Before prefixes, tokens were 40-character hexadecimal strings that were indistinguishable from SHA hashes.
| Prefix | Type | Issued by | Format notes for detection | Credential revocation API |
|---|---|---|---|---|
| ghp_ | Classic PAT | User, in Settings, Developer settings | Prefix, Base62 body, trailing checksum | Supported |
| github_pat_ | Fine-grained PAT | User, in Settings, Developer settings | Match on the literal github_pat_ string | Supported |
| gho_ | OAuth app access token | GitHub, when a user authorises an OAuth app | Prefix, Base62 body, trailing checksum | Supported |
| ghu_ | GitHub App user access token | GitHub, when a user authorises a GitHub App | Prefix, Base62 body, trailing checksum | Supported |
| ghs_ | GitHub App installation access token | GitHub, when the app exchanges its JWT for an installation token | Being moved to a stateless ghs_APPID_JWT form since 27 April 2026; do not assume 40 characters | Not in the documented list; the app owner revokes it or lets it expire |
| ghr_ | GitHub App refresh token | GitHub, alongside an expiring ghu_ token | Prefix, Base62 body, trailing checksum | Supported |
The stateless installation token format matters for anyone writing parsers or scanners. GitHub's note says that apps expecting installation tokens to be exactly 40 characters long may not handle the new format, and offers a temporary request header so teams can test against it on demand. Treat token length as variable for every type and anchor detection on the prefix. Token prefixes for other providers sit in the Git Secret Scanning Guide; this page stays with GitHub's own formats.
- Never paste a suspected token into a public tool: checking a string against a third-party "token decoder" is itself a disclosure. Identify it by prefix, then revoke.
- Enterprise Server: the same prefixes are documented for GitHub Enterprise Server, but the credential revocation API and public repository auto-revocation are GitHub.com features. Confirm behaviour against the docs for your server version.
Scopes, lifetimes and expiry
Fine-grained and classic personal access tokens
GitHub recommends fine-grained PATs over classic ones wherever possible. The differences that matter during an incident are below.
| Property | Fine-grained (github_pat_) | Classic (ghp_) |
|---|---|---|
| Resource owner | One user or one organisation per token | Every organisation and repository the user can reach |
| Repository selection | All repositories of the owner, or selected repositories | No per-repository selection |
| Permission model | Fine-grained permissions per resource, read or write | OAuth scopes such as repo, workflow, admin:org |
| Organisation approval | Can be required by organisation owners; "Require administrator approval" is the default policy | Not subject to approval; organisations can only restrict classic PATs entirely |
| Expiry | 1 to 366 days or none, subject to maximum lifetime policy; default organisation maximum is 366 days | Optional; no expiration requirement unless an organisation or enterprise sets a maximum lifetime |
| Organisation visibility | Organisation owners can view and revoke individual tokens that access the organisation | Organisation owners cannot see individual tokens |
GitHub documents gaps that still push some users to classic tokens: contributing to public repositories where the user is not a member, working as an outside collaborator, accessing several organisations at once, Packages, the Checks API and user-owned Projects, plus enterprise-level APIs and internal resources on Enterprise Cloud. When you find a classic PAT, ask which of these it is for; if none, it is a migration candidate. See How to migrate from GitHub classic PATs to fine-grained tokens or GitHub Apps.
GitHub App and OAuth app tokens
- Installation tokens (ghs_): expire after 1 hour. The app mints them by signing a JWT with its private key, so the real long-lived secret is that key. See the GitHub App Private Key Security Guide.
- User access tokens (ghu_): expire after 8 hours by default and come with a ghr_ refresh token that expires after 6 months. App owners can opt out of expiry so ghu_ tokens never expire; GitHub states this is not recommended. If expiry is re-enabled later, tokens issued before the change do not expire and should be deleted.
- OAuth app tokens (gho_): long-lived. GitHub limits each user, application and scope combination to ten tokens and revokes the oldest unused or least recently used token when an eleventh is created.
- GITHUB_TOKEN: created at the start of each Actions job and expires when the job completes. Its permissions are set in the workflow; see How to Restrict GITHUB_TOKEN Permissions in Workflows.
Automatic revocation by GitHub
GitHub revokes a valid OAuth token, GitHub App token or PAT automatically when it is pushed to a public repository or public gist, and revokes OAuth tokens and PATs that have not been used for one year. Expired or revoked tokens cannot be restored. An expiry or revocation can appear as an oauth_authorization.destroy action in the user's security log.
Revoking and rotating each type
The fastest correct action depends on the prefix and on your role. The table follows GitHub's credential types reference. Step-by-step handling of a leaked PAT, including checking what it touched, is in How to revoke a leaked GitHub personal access token and check what it touched.
| Prefix | Token owner | Organisation or enterprise owner | Anyone with the value |
|---|---|---|---|
| ghp_ | Delete in Settings, Developer settings, Tokens (classic) | Restrict classic PAT access to the organisation; revoke SSO authorisation on Enterprise Cloud with SSO | Submit to the credential revocation API |
| github_pat_ | Delete in Settings, Developer settings, Fine-grained tokens | View and revoke the individual token; restrict fine-grained PAT access | Submit to the credential revocation API |
| gho_ | Revoke the OAuth app authorisation in account settings | Deny the previously approved OAuth app's access to the organisation | Submit to the credential revocation API |
| ghu_ | Revoke the GitHub App authorisation (this applies to all organisations) | Suspend or uninstall the app | Submit to the credential revocation API |
| ghr_ | Revoke the GitHub App authorisation, which invalidates refresh tokens | Suspend or uninstall the app | Submit to the credential revocation API |
| ghs_ | App owner calls DELETE /installation/token, or waits for the 1-hour expiry | Uninstall the app, which deactivates its installation tokens | Report to the app owner; rotate the app private key if it is exposed |
Two caveats from GitHub's documentation catch responders out. When an organisation owner revokes a fine-grained PAT, SSH keys created by that token keep working and the token can still read public resources in the organisation. Revoking SSO authorisation on Enterprise Cloud blocks a credential from that organisation without deleting it, and the user cannot re-authorise the same credential afterwards. The credential revocation API needs no authentication, so GitHub cannot tell you who reported a token; treat its use as containment, not attribution.
Incident-scale actions
On GitHub Enterprise Cloud, enterprise owners can lock down SSO, revoke SSO authorisations for a user, a credential type or everyone, and, for Enterprise Managed Users only, delete credentials outright. GitHub warns these bulk actions are likely to break automation and may take months to unwind, so use the narrowest option that contains the incident. The wider response is in the GitHub Organisation Compromise Playbook.
- Identify the type from the prefix and record where it was found, without copying the value into tickets or chat.
- Revoke using the route in the table above. For ghs_ tokens, check whether the app private key is also exposed.
- Find the owner: the user for ghp_, github_pat_, gho_, ghu_ and ghr_; the app and installation for ghs_.
- Review audit log activity for the token and owner over the exposure window. See How to investigate a compromised GitHub account.
- Issue a replacement with narrower scope and an expiry, or move the use case to a GitHub App.
- Close the secret scanning alert with the correct resolution so metrics stay accurate.
Detecting leaked GitHub tokens
Prefixes make GitHub tokens one of the easiest secret types to detect, provided scanning is switched on where the tokens live. GitHub's own controls are listed below; deeper setup is in the GitHub Advanced Security Configuration Guide and How to enable GitHub secret scanning push protection.
- Secret scanning: runs automatically and free on public repositories. Private and internal organisation repositories need GitHub Secret Protection on GitHub Team or Enterprise Cloud. It scans full Git history on all branches plus issues, pull requests, Discussions and wikis.
- Push protection for users: enabled by default on GitHub.com for each account and blocks pushes of supported secrets to public repositories.
- Push protection for repositories: needs GitHub Secret Protection and is disabled by default. By default anyone with write access can bypass with a reason, which creates an alert and an audit log entry; delegated bypass limits who can do this.
- Validity checks: when enabled, secret scanning can check with the issuer whether a detected secret is still active, which helps triage old alerts.
- Your own scanners: match ghp_, gho_, ghu_, ghs_, ghr_ and github_pat_ in CI logs, ticketing systems, chat exports and endpoint files. Use the checksum to discard false matches where your tool supports it.
Handling of a fired alert is covered in How to respond to a GitHub secret scanning alert. GitHub's guidance is to rotate the credential first, because rotation is more effective than scrubbing history.
Metrics
- Classic PAT count: number of ghp_ tokens with organisation access, trending to zero outside the documented gap cases.
- Non-expiring tokens: share of fine-grained PATs with no expiry and GitHub Apps opted out of user token expiry.
- Time to revoke: median time from secret scanning alert to revocation, by prefix.
- Push protection bypass rate: bypasses per hundred blocks, and the share using "I'll fix it later".
- Coverage: percentage of private and internal repositories with secret scanning and push protection enabled.
Framework mapping
| Framework | Reference | How this page applies |
|---|---|---|
| MITRE ATT&CK | T1528 Steal Application Access Token; T1550.001 Application Access Token; T1552.001 Credentials In Files | Leaked and reused GitHub tokens |
| NIST SP 800-53 Rev. 5 | IA-5 Authenticator Management; AC-2 Account Management; AC-6 Least Privilege | Expiry, revocation and scope limits per token type |
| NIST CSF 2.0 | PR.AA-01; PR.AA-05; DE.CM-03 | Credential management, least privilege and leak monitoring |
For the wider picture of GitHub as an identity platform, see the GitHub Personal Access Tokens Security Guide and the GitHub and GitHub Actions Security Guide.
Practitioner checklist
- Load all six documented prefixes into every scanner you run, and match on prefix rather than fixed length.
- Test parsers and token-handling code against the stateless ghs_ installation token format.
- Set a maximum lifetime for fine-grained and classic PATs at organisation or enterprise level.
- Keep "Require administrator approval" for fine-grained PATs and restrict classic PAT access where the gap cases do not apply.
- Check every GitHub App you own still issues expiring user access tokens.
- Enable secret scanning and repository push protection on private and internal repositories, with delegated bypass.
- Write a revocation runbook per prefix that names who acts and through which route.
- Inventory unprefixed credentials, SSH keys and deploy keys, separately.
Standards and references
- GitHub Docs: GitHub credential types reference
- GitHub Docs: About authentication to GitHub
- GitHub Docs: Token expiration and revocation
- GitHub Docs: Managing your personal access tokens
- GitHub Docs: Setting a personal access token policy for your organization
- GitHub Docs: Refreshing user access tokens
- GitHub Docs: About push protection
- GitHub Blog: Behind GitHub's new authentication token formats
Related NHI Mgmt Group resources: GitHub Personal Access Tokens Security Guide · GitHub Apps vs Personal Access Tokens vs OAuth Apps · How to revoke a leaked GitHub personal access token and check what it touched · Git Secret Scanning Guide