Skip to content

Allow requesting a shorter Access Token lifetime #14968

Open

Description

@fproulx-boostsecurity

Describe the feature or problem you’d like to solve

The new expiring credentials are a welcome improvement. GitHub documents an eight-hour lifetime for the resulting OAuth access token, however, and I’d like the option to use a shorter lifetime.

A local script or tool can obtain the current bearer token using gh auth token. Depending on when it obtains the token, a copied token may remain usable for much of its eight-hour lifetime, with the permissions granted to the CLI credential. A 15- or 60-minute lifetime could reduce the exposure window for an access-token-only leak.

Proposed solution

Allow users or organizations to request a shorter, server-enforced access-token lifetime for GitHub CLI OAuth credentials, while continuing to use the refresh token for normal CLI operation.

Users could choose from a small set of lifetimes, or an organization could define an upper bound. The exact values and defaults could be determined by GitHub.

Shorter lifetimes would increase refresh frequency and could affect rate limits, concurrency, offline workflows, and tools that cache gh auth token output. They would reduce the useful lifetime of a stolen access token, but would not address theft of the refresh token or ongoing malicious code execution on the endpoint.

I understand the OAuth server determines the token’s actual expiration, and I could not find a documented way for gh to request a shorter lifetime today. Could the OAuth platform support this, and could gh expose it if available?

Additional context

A client-side decision to stop using a token earlier would not invalidate an already copied token on GitHub. Narrower scopes and repository access would further reduce impact, but are separate from this lifetime request.

Activity

  1. added
    needs-triage
    on Nov 6, 2026
  2. cli-triage commented on Nov 6, 2026

    @cli-triage

    GitHub CLI 2.103.3 supports requesting refreshable credentials with gh auth login --expiring, but it does not offer a duration setting. The released help also says the request is only a preference and that issuance depends on the host and OAuth app configuration.

    This request therefore covers a remaining capability: allowing a user or organization to ask GitHub's OAuth service for a shorter, server-enforced access-token lifetime, then exposing that choice in gh if the platform supports it. The existing short-lived token issues implemented refreshable credentials, not configurable access-token durations.

    Supporting reports

    Generated by issue triage.

  3. deleted a comment from cli-triage on Nov 6, 2026
  4. added
    enhancement
    gh-auth
    on Nov 9, 2026
  5. removed
    needs-triage
    on Nov 9, 2026
  6. github-actions commented on Nov 9, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-auth

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions