GitHub CLI now provides an opt-in public preview for expiring OAuth credentials that can refresh automatically. The capability is available with GitHub CLI version 2.103.0 or later and is intended to reduce the useful lifetime of an exposed access token without requiring developers to authenticate manually every few hours.
The feature is backward compatible: existing sign-ins and manually supplied tokens continue to work without opting in. However, token issuance depends on the host and its OAuth application configuration, so requesting expiring credentials does not guarantee that every login will receive them.
What changed in GitHub CLI
With expiring credentials enabled, GitHub CLI stores an expiring access token together with a rotating refresh token. When the access token needs renewal, the CLI can exchange the refresh token for a new access-token and refresh-token pair.
The underlying GitHub OAuth model documents access tokens that last eight hours and refresh tokens that last six months. Those are general OAuth lifetimes, not an unconditional promise for every GitHub CLI login or host. The actual behavior depends on platform support and OAuth app configuration.
GitHub CLI can refresh credentials before returning them through commands such as gh auth token. The --no-refresh option can be used when the current token must be inspected without triggering a refresh. Similarly, gh auth status can show authentication state and token expiry, with an option to avoid refreshing.
The change is documented in GitHub’s October 21, 2026 changelog announcement and the GitHub CLI authentication manual.
How to opt in
To request expiring credentials for a single login, use:
gh auth login --expiringTo make expiring credentials the preferred behavior for sign-ins generally, set the CLI configuration value:
gh config set expiring_credentials enabledThe setting expresses a preference; it does not override a host or OAuth application that does not support expiring credentials. If the host cannot issue them, GitHub CLI falls back to a non-expiring token and provides informational feedback.
When changing scopes with gh auth refresh, preserve the expiring-credential behavior by using --expiring or by keeping the expiring_credentials preference enabled. This matters because a later scope change should not unexpectedly replace the intended authentication mode.
What this means for Git over HTTPS
Developers who use HTTPS Git operations should configure GitHub CLI as Git’s credential helper so Git can receive refreshed credentials rather than relying on a stale cached token. The setup command is:
gh auth setup-gitFor a specific host, use:
gh auth setup-git --hostname github.comGit 2.46 or newer is recommended because it provides improved handling for expiring credential lifetimes, including the ability to mark expiring credentials as non-cacheable. Without an appropriate credential-helper setup, Git workflows or other tooling may continue using a previously cached token after it expires.
This requirement is especially important for teams adopting the preview in automated development environments. A command-line login can refresh its own credential, but an unrelated process that has copied the token into a long-lived cache may not have the same behavior.
Why developers and administrators should care
An expiring access token has a shorter useful lifetime if it is accidentally exposed. That can reduce the potential impact of token leakage compared with a credential that remains valid indefinitely. The feature is a credential-security improvement, not a response to a reported vulnerability or security incident.
There is a corresponding compatibility cost. Scripts, extensions, and integrations that call gh auth token once and store the returned value for a long period may begin failing when that token expires. Automation should obtain credentials when needed rather than assuming that a previously printed token remains valid.
Teams should also review where GitHub CLI stores credentials. The CLI manual notes that credential storage can fall back to plaintext when no secure credential store is available. Automatic refresh does not make every local storage arrangement secure, so administrators should assess the credential-store behavior of the operating systems and environments where the CLI runs.
Availability and platform caveats
The capability is an opt-in public preview. GitHub.com is supported by the supplied documentation, and GitHub Enterprise Cloud is covered as well. Dedicated enterprise subdomains and API endpoints using ghe.com are associated with GitHub Enterprise Cloud with data residency, although the available documentation does not establish that every use of a ghe.com host is interchangeable with that product label.
Server support requires additional care. The available documentation states that the underlying OAuth improvements are scheduled for GitHub Enterprise Server 3.23, while a versioned GitHub Enterprise Server 3.18 page states that expiring tokens are not available there. This establishes 3.23 as a relevant availability milestone, but it should not be treated as a definitively documented universal minimum for every GitHub CLI flow or configuration.
Before enabling the preview across an organization, administrators should confirm the target GitHub platform, server version, and OAuth application configuration. Unsupported environments will use non-expiring credentials instead.
What you should do
- Upgrade first. Install GitHub CLI 2.103.0 or later before requesting expiring credentials.
- Test an individual login. Run
gh auth login --expiringin a test account or environment and usegh auth statusto inspect the resulting authentication state and expiry. - Configure Git for HTTPS. Run
gh auth setup-git, or specify a host with--hostname, so Git can use refreshed credentials. - Review automation. Find scripts and extensions that cache output from
gh auth token. Prefer obtaining a current token when it is needed, and use--no-refreshonly when inspecting the existing token is intentional. - Check your Git version. Git 2.46 or newer is recommended for better lifetime-aware credential caching.
- Preserve the setting after scope changes. Use
gh auth refresh --expiringor keep the CLI preference enabled. - Validate the platform. Confirm whether the relevant GitHub.com, GitHub Enterprise Cloud, or GitHub Enterprise Server environment supports the capability before broad deployment.
The preview is most useful for teams that want shorter-lived access tokens while retaining routine CLI authentication. It should nevertheless be tested against local credential storage, Git credential helpers, scripts, and hosted or self-managed GitHub environments before becoming a standard authentication policy.
Sources
- GitHub Changelog: GitHub CLI opt in to expiring, auto-refreshing OAuth tokens
- GitHub CLI manual: gh auth login
- GitHub CLI documentation: Authenticating with GitHub CLI
- GitHub documentation: Authorizing OAuth apps
- GitHub Changelog: Multiple redirect URIs and token refresh for OAuth apps
- GitHub Enterprise Server 3.18 documentation: Authenticating with GitHub CLI
- GitHub Enterprise Cloud documentation: Data residency


