Key takeaways
- Public repo fetches from raw.githubusercontent.com work anonymously, so an expired token is often ignored and the fetch still succeeds.
- Private repo raw fetches fail with a 404 rather than a 401 when a token expires, making the breakage look like a missing file.
- Classic PATs can be set with no expiration, while fine-grained PAT lifespans can be capped by organization policy.
- The Actions GITHUB_TOKEN is minted per workflow run and expires when the job finishes, so it never needs rotation.
- Track each token's expiry date and owner proactively, because raw fetch failures surface days after the credential dies.
GitHub raw token expiration works differently from the REST API: classic PATs and fine-grained PATs can expire on a set date, but raw.githubusercontent.com often serves content anonymously, so an expired token may return a 404 or 401 instead of the clean 401 you expect. This guide separates API-level expiry from raw fetch behavior across classic PATs, fine-grained PATs, and the Actions GITHUB_TOKEN.
Does raw.githubusercontent.com require a token at all?
Usually no. Fetching a file from a public repo via raw.githubusercontent.com works anonymously, with no Authorization header. That is the core difference from api.github.com, where unauthenticated requests are rate-limited at 60 per hour per IP. Raw fetches of public content do not consume that REST quota, which is why CI jobs pulling public files often run for years without a credential.
Public repos: anonymous fetch behavior
Anonymous access means anonymous behavior: no token expiry to track, but also no audit trail tying a fetch to a person or a service. If a pipeline silently switches from a token to anonymous because the token expired and the fetch still worked, you lose attribution without noticing.
Private repos: which token formats raw accepts
Private repo fetches require a token, and raw accepts the same formats as the API: classic PATs, fine-grained PATs, and OAuth tokens. A classic PAT can be set with no expiration at all, which is exactly how orphaned credentials accumulate. GitHub's docs cover classic PAT expiry and its notifications in managing your personal access tokens. For tracking which token belongs to which pipeline before it expires, see our October 2026 credentials brief.
When does a GitHub personal access token expire?
When you create a classic PAT, GitHub asks you to pick an expiration: 7, 30, 60, or 90 days, a custom date, or "no expiration." A custom date can extend up to a year out. "No expiration" means the token stays valid until you revoke it or GitHub disables it for security reasons, so it never lapses on its own.
Fine-grained PATs behave similarly, but your organization may cap the maximum lifespan you can select.
GitHub emails you before a token expires, with reminders as the deadline approaches. That helps if the token belongs to you. If it belongs to a departed engineer and lives in a Postman collection or CI variable, the email goes nowhere useful.
That gap is why expiry dates alone are not enough. You need to know who owns each token and what breaks when it lapses, which is the problem credential expiration reminder tools for IT teams are built to solve.
How do fine-grained PAT expiration policies differ from classic tokens?
Classic PATs let you pick any expiration date from 7 days to "no expiration" at creation time, and nothing at the organization level can shorten it. Fine-grained PATs are scoped to specific repositories and permission sets, and they inherit an additional layer of control: organization owners can block access entirely or cap how long any fine-grained token touching their org's resources can live. GitHub documents these limits and org-level token policies in its fine-grained PAT documentation.
The practical difference:
| Classic PAT | Fine-grained PAT | |
|---|---|---|
| Max lifetime you can set | No expiration | Bounded by org policy |
| Org can cap lifetime | No | Yes |
| Permission scope | Coarse (user-level scopes) | Per-repo, per-permission |
| Expiry visibility to the org | None | Org sees tokens with access |
If your rotation policy is 30/60/90 days, fine-grained tokens give the org a way to enforce it; classic tokens rely on the person who created them. Track ownership metadata per token so an expiry never lands on an unclaimed key — see these API key expiration policy examples.
What happens when an expired token is used against raw.githubusercontent.com?
An expired token against raw.githubusercontent.com gets a 401 Unauthorized on a private repo. On a public repo, the same expired token often still works, because raw content for public repos is served anonymously and the invalid credential is effectively ignored. That asymmetry is why "does the token still work" is the wrong test for whether it has expired.
Why a broken raw fetch looks like a 404, not an auth error
The failure mode that costs teams hours is a private repo fetch returning 404 instead of 401. GitHub deliberately returns 404 for private resources when authentication fails, so an expired token and a deleted file are indistinguishable from the client's side. A pipeline that was pulling a config file yesterday reports "not found" today, and the first instinct is to check the path, the branch, or the repo name rather than the token's expiry date.
Caching makes it worse. A CDN or CI layer that cached the raw response keeps serving stale content after the token dies, so the breakage surfaces days later, on a different runner, with no error pointing at the credential. By then, correlating the failure with the token's expiry window requires an audit trail of which token the job used and when it lapsed. That gap between expiry and visible failure is exactly what a lifecycle monitoring layer closes, by tracking metadata like expiry dates and owners without holding the secret value itself (https://keyguardrail.com/brief/token-handling-october-2026).
How does the Actions GITHUB_TOKEN expiration differ from user PATs?
The Actions GITHUB_TOKEN is an installation token that GitHub mints per workflow run and kills when the job finishes. Its lifetime is measured in hours, not days, and you never set or rotate it — GitHub handles issuance and expiry entirely, so it never appears in your rotation policy or your vault (GitHub Docs). That short lifetime is why it never breaks a raw fetch mid-quarter the way a forgotten PAT does. The trade-off is scope: GITHUB_TOKEN only reaches the repository the workflow runs in, so pulling raw content from a different private repo, an external organization, or a third-party API still requires a PAT stored as a secret. Those PATs are the ones that expire on your schedule and need an owner. Inventory them alongside your AWS and SaaS keys — tracking API key expiry covers the lifecycle side.
How do you check a token's expiration date before it breaks a raw fetch?
Both token types expose expiry through the REST API. For a fine-grained PAT, GET /applications/{client_id}/token returns the token's expires_at timestamp. For classic PATs, there is no single endpoint that reports expiry directly, so the practical route is the settings page (Settings → Developer settings → Personal access tokens), which lists each token's expiration date alongside its scopes.
Fine-grained PATs also show expiry in the token list on the same settings page, so a quick manual audit is a browser session away. The gap is that nobody opens that page on a schedule.
A CI check for token expiry
Because raw fetches fail silently on expiry (you get a 404, not a 401), the reliable check is proactive: run a scheduled job that queries the API for each token's expires_at and alerts when it falls inside your rotation policy window, say 30 days out. Store the token IDs and owners in a manifest, not the secrets themselves, so the check needs no secret custody. If you already run a vault like Infisical or HashiCorp Vault, the same job can read expiry metadata alongside the secret value and flag anything past its rotation deadline.
What is the recommended expiration window for tokens used in raw content workflows?
Pick the shortest window your rotation process can reliably hit. For CI pipelines that fetch raw content, GitHub's own guidance is to use the Actions GITHUB_TOKEN where possible, since it is scoped to the repository and lives only for the job's duration (GitHub Docs on token security). That is the short-lived creds end of the spectrum, and it removes expiry from your tracking list entirely.
When a user PAT is unavoidable, the common 30/60/90-day rotation policy is a compromise between blast radius and operational load. A 30-day window caps how long a leaked token works but means twelve rotation deadlines a year per token; 90 days cuts the workload but triples exposure time. Match the window to the token's scope: read-only tokens fetching public raw content can sit at 90 days, while anything touching private repos earns 30.
The honest test: if your team misses rotation deadlines at 30 days, a 90-day policy you actually follow beats a 30-day policy you ignore.
How do you track who owns each token before it expires?
An expiry date tells you when a token dies. It doesn't tell you which pipeline breaks when it does, or who to ping 30 days out. That gap is why teams with a vault still get paged: Secrets Manager, Vault, and Infisical store and deliver secret values, but none of them natively answers "who owns this key and when does it expire" across AWS, Stripe, and GitHub in one view.
That's the gap KeyGuardRail targets. It monitors credential lifecycle metadata — owner, expiry, rotation deadline — without ever holding the secret value itself. Your vault stays the system of record for secrets; KeyGuardRail becomes the coordination layer for what happens next. Self-serve signup, Starter tier, owners like "Payments platform" or "Platform engineering" attached to each credential.
Running the same criteria against our own product
Honest limits: KeyGuardRail doesn't rotate keys for you, and it doesn't replace your vault — it watches metadata only. If a token's owner leaves and nobody updates the record, expiry alerts still fire, but ownership is only as accurate as the metadata your team maintains.
FAQ
Do GitHub raw links stop working when a token expires?
For public repos, usually no. Raw content is served anonymously, so an expired token is effectively ignored and the fetch still succeeds. For private repos, yes: the fetch fails with a 404 rather than a clean 401, which is why the breakage looks like a missing file instead of an authentication problem.
Can I use a fine-grained PAT with raw.githubusercontent.com?
Yes. Raw accepts the same token formats as the REST API: classic PATs, fine-grained PATs, and OAuth tokens. Fine-grained PATs are scoped to specific repositories and permissions, and your organization can cap their maximum lifespan, which classic PATs do not allow. Either type works for private repo fetches.
How long does the GITHUB_TOKEN last in GitHub Actions?
The GITHUB_TOKEN is minted per workflow run and killed when the job finishes, so its lifetime is measured in hours, not days. You never set or rotate it; GitHub handles issuance and expiry entirely. Its scope is limited to the repository the workflow runs in, so other repos need a PAT.
What is the maximum expiration for a GitHub personal access token?
A classic PAT can be set with no expiration at all, meaning it stays valid until you revoke it or GitHub disables it. A custom expiration date can extend up to a year out. Fine-grained PATs may be capped shorter by organization policy, so the org can bound their lifetime.
Why does my raw file fetch return 404 after my token expired?
GitHub deliberately returns 404 for private resources when authentication fails, so an expired token and a deleted file look identical from the client's side. Caching can delay the symptom further: a CDN or CI layer keeps serving stale content after the token dies, so the failure surfaces days later pointing nowhere near the credential.
