GitHub apps need expiring user tokens from 5 Jan 2027: refresh-token guide
From 5 January 2027 new GitHub Apps and OAuth apps can no longer issue non-expiring user tokens: access tokens last eight hours, so refresh handling is required.
· 6 min read
Written by AI from the sources linked below. How we use AI
On this page
From 5 January 2027, every new GitHub App and OAuth app registered on GitHub.com or GHE.com will issue only expiring user access tokens. The checkbox that let developers opt out and hand users tokens that never expire is being removed from the registration form. Tokens already issued are not touched. If you are building a new integration, or you maintain a template, SDK or tutorial that registers apps for other people, you need refresh-token handling in place before that date.
Key points
- Starting 5 January 2027, newly registered GitHub Apps and OAuth apps support only expiring user access tokens; the opt-out setting disappears (GitHub changelog, 4 December 2026).
- A user access token for a new app expires after eight hours (28,800 seconds); the refresh token that comes with it is valid for six months (15,897,600 seconds).
- Tokens issued before 5 January 2027, and apps registered before it, are not affected by this change.
- A refresh token works once: after you use it, the old refresh token and the old access token stop working, and you get a new pair.
- You can test today by sending the
offline_accessscope, which forces an expiring token even for an app configured the old way.
What to do
Who is affected: anyone who registers a new GitHub App or OAuth app on or after 5 January 2027 and whose code assumes a user token lasts until it is revoked. Existing apps keep working as configured. Self-hosted GitHub Enterprise Server is a special case, covered below.
- Check your auth library. Look for support for the
refresh_tokengrant in your OAuth or GitHub App SDK. If it has none, you will need to add it, or the first user session will break after eight hours. - Store both tokens. Keep the access token (prefix
ghu_) and the refresh token (prefixghr_), plus the expiry times, for each user. - Refresh before or on failure. Send a POST to
https://github.com/login/oauth/access_tokenwithclient_id,grant_type=refresh_tokenand therefresh_token. Aclient_secretis required unless the original token came from the device flow. - Write the new pair back atomically. Because each refresh token is single use, two workers refreshing the same user at the same moment can invalidate each other. Serialise refreshes per user (a lock or a compare-and-swap on the stored token).
- Test now with
offline_access. Addoffline_accessto thescopeparameter of your authorisation request. You get an expiring token and a refresh token even if the app is configured to issue non-expiring ones. The parameter grants no permissions; it only forces expiry. - Plan for sign-in on refresh failure. If a refresh token expires unused, send the user through the web application flow or device flow again.
If you already run an app with non-expiring tokens: nothing is forced yet, but GitHub's documentation recommends opting in. If you turn expiration on after users already signed in, their existing tokens keep never expiring. GitHub's documentation says to delete them with the DELETE /applications/CLIENT_ID/token endpoint or make users sign in again so they receive expiring ones.
What happened
On 4 December 2026 GitHub published a changelog entry titled "New GitHub Apps and OAuth apps require expiring user tokens". It says that starting 5 January 2027 newly registered apps support only expiring user access tokens, and that tokens issued before then are not affected. It also says expiring tokens were already on by default for new apps, but developers could opt out during registration and issue tokens that never expire. That opt-out is the part going away.
GitHub's stated reason is simple: a non-expiring token stays valid until someone revokes it, so a leaked token can be used indefinitely, and requiring expiry limits that exposure for every new app. The change applies to GitHub.com and GHE.com. The changelog does not announce a date for forcing existing apps to switch, and we did not find one in the documentation either.
Background
Expiring tokens are not new to GitHub. GitHub Apps have had them for years: the documentation says GitHub App user access tokens expire by default, with the setting under the app's Optional Features, where the "User-to-server token expiration" item can be switched on if an older app opted out.
OAuth apps came later. A GitHub changelog entry dated 14 August 2026 ("Multiple redirect URIs and token refresh for OAuth apps") let OAuth apps opt in to an access token that lives eight hours with a refresh token valid for six months. It said short-lived tokens were already enabled by default for new applications, that the offline_access scope was the way to test and roll out the change, and that apps could temporarily disable the default while updating an SDK that lacked refresh support. The 5 January change closes that exit for new registrations.
It is also one of several GitHub platform changes in a short window. GitHub is rejecting OAuth redirect URI fragments from 1 February 2027, changing organisation limits from 5 January 2027 and blocking pull_request_target by default. If you maintain GitHub integrations, it is worth reading them together.
The industry direction is consistent with the OAuth security best current practice, RFC 9700, which says refresh tokens for public clients must be sender-constrained or use refresh token rotation. GitHub's refresh tokens are single use, which matches the rotation approach.
How it works
The lifetimes come from GitHub's documentation for refreshing user access tokens. The access token's expires_in value is always 28800 seconds, and the refresh token's refresh_token_expires_in is always 15897600 seconds.
The refresh response contains access_token, expires_in, refresh_token, refresh_token_expires_in, scope (always an empty string for GitHub Apps, because the token is limited to the permissions both the app and the user have) and token_type (always bearer). In practice an app should treat the access token like a cache entry: use it until it is within a minute or two of expiry, or until a call returns 401, then refresh once and retry.
The OAuth apps documentation adds one detail worth noting: if your app supports both GitHub Enterprise Server and GitHub.com, be prepared for offline_access to have no effect, because a GHES instance may not support expiring tokens yet. In that case you receive a non-expiring token and no refresh token, so your code must not assume that a refresh token is always present.
What it means
For developers of new apps: the refresh flow stops being optional. The cost is real but small: a token store with expiry times, a refresh call and a per-user lock. The benefit is that a leaked database dump or log line contains tokens that are dead within eight hours, unless the attacker also holds a refresh token and gets to it first.
For SDK and tutorial authors: every guide that tells beginners to paste a token into an environment variable or a database column and forget about it will produce apps that stop working on day one. Starter kits that register apps through the API or a manifest should be tested against expiring tokens.
For security teams: this reduces the standing exposure of new integrations, but only for new ones. Older apps with non-expiring tokens remain, and the single largest improvement is still to find them, rotate them and move them to expiring tokens. Treat the new rule as a nudge, not a cleanup.
For users: nothing changes on sign-in screens. If an app fails to refresh properly, you may be asked to sign in again more often than before.
What we don't know yet
- Whether GitHub plans to force existing apps onto expiring tokens. Neither the changelog nor the documentation we read says so.
- The exact behaviour for GitHub Enterprise Server. The changelog covers GitHub.com and GHE.com; the OAuth documentation warns that Server instances may not yet support expiring tokens.
- How GitHub will handle apps that are registered through automated flows or the manifest flow after the cut-off. The documentation we read describes the setting in the interface only.
What to watch next
- The 5 January 2027 effective date, when the opt-out checkbox is removed.
- The 1 February 2027 rejection of redirect URI fragments, which affects the same sign-in code paths.
- Updates to GitHub's documentation on Enterprise Server support.
Sources
- GitHub changelog: New GitHub Apps and OAuth apps require expiring user tokens (4 December 2026)
- GitHub Docs: Refreshing user access tokens
- GitHub Docs: Authorizing OAuth apps
- GitHub changelog: Multiple redirect URIs and token refresh for OAuth apps (14 August 2026)
- IETF RFC 9700: Best Current Practice for OAuth 2.0 Security
Written by
The official account of the people who run audiotale.net: announcements, conversation starters and the newsroom's drafts. Posts written with AI say so. Every other account here is a real person.
Read next
GitHub SHA-256 repositories in public preview: how to try them, what breaks and what's missing
GitHub now lets you create new repositories that use SHA-256 instead of SHA-1; the choice is permanent, object IDs grow to 64 characters, and migration is not available yet.
audiotale.net team7 min read
GitHub blocks pull_request_target by default from 2 December 2026: how to fix broken workflows
GitHub Actions now blocks pull_request_target in public repositories unless a policy allows it; here is who is affected, how to check, and the three ways to fix a stopped workflow.
audiotale.net team8 min read
GitHub OAuth redirect URI fragments rejected from 1 February 2027: how to fix your callback URL
GitHub will reject OAuth sign-in requests whose redirect URI contains a # fragment from 1 February 2027. Here is who is affected, what to change and how to check your apps.
audiotale.net team8 min read