Skip to content

Feature Request: Per-Device OAuth Token Management for GitHub CLI Authentication #11420

Open

Description

@TonyXiang8787

Describe the feature or problem you’d like to solve

Currently, when using gh auth login with the OAuth flow, the generated authentication token is not tied to a specific device or session. All logins using the GitHub CLI (gh) for a given user account via OAuth share the same token, and revoking OAuth access removes access from all devices at once. There is no way to revoke access to just one specific device or CLI session when OAuth is used.

This creates challenges for security and access management, particularly in these scenarios:

  • If a device is lost, stolen, or decommissioned, users cannot revoke just that device's CLI access—they must revoke OAuth access for all devices.
  • Users lack visibility and control over which machines are authorized to use CLI via OAuth for their account.

Proposed solution

  • Implement per-device/session OAuth token management for GitHub CLI authentication.
  • Each gh auth login instance (on a new machine or user profile) should create a unique, device-tied OAuth token.
  • Show a list of all active OAuth device tokens in the GitHub UI under Developer Settings, including device name, creation date, and last used info.
  • Allow tokens to be individually revoked from the GitHub web UI, terminating CLI OAuth access for only the targeted device/session.
  • Optionally, allow users to name devices during gh auth login for easier identification.

Additional context

This would bring OAuth-based CLI access management in line with how many cloud platforms handle per-device/session tokens. It would make it easier for users to manage authorized CLI environments and respond quickly to security incidents without broad disruption.

Activity

  1. added
    enhancement
    on Jul 31, 2025
  2. github-actions commented on Jul 31, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature 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.

  3. added
    needs-triage
    on Jul 31, 2025
  4. self-assigned this
    on Aug 1, 2025
  5. added
    needs-investigation
    on Aug 1, 2025
  6. babakks commented on Aug 1, 2025

    @babakks
    Member

    Thanks for submitting the issue, @TonyXiang8787! 🙏

    This issue touches a wide range of concepts/domains so apologies for my long comment. I'll try to organise it into a couple of sections.

    Identical tokens

    I understand from your explanation that you're observing identical tokens being generated for independent gh auth login calls. Please correct me if I'm wrong. But if that's what you're saying, I kind of have a strong opinion that OAuth, as a standard, would never allow such a thing for the reasons you've already mentioned. Also, I checked and can confirm that every gh auth login ends up in a different token regardless of the host machines on which you run the command.

    So, can you please tell me more about your situation so that I can reproduce it on my end?

    Managing tokens via gh

    gh solely relies on the public GitHub API (REST and GraphQL). As I quickly checked I could find only one endpoint that can be used to revoke a given set of credentials (See here). This is too little to develop a decent set of gh commands out of it.

    Improvements to the web GUI

    These suggestions are out of the scope of gh. I have to check, but I guess admins of a GitHub Enterprise Server (GHES) or an Enterprise Organization are already provided with some web GUI tools to handle the revocation of tokens.

  7. added
    more-info-needed
    and removed
    needs-investigation
    on Aug 1, 2025
  8. TonyXiang8787 commented on Aug 6, 2025

    @TonyXiang8787
    Author

    Dear @babakks,

    Thank you very much for your extensive reply.

    Identical tokens

    I might have not described the token very correctly in the original post. I am not sure if the OAuth tokens are exactly the same. What I meant is that I cannot find different device OAuth token management from the GitHub webpage.

    Device management

    The problem is, we cannot currently revoke the access for one particular device which is authenticated via gh auth login using https and OAuth. I would like to see this function in case of for example stolen laptop.

    We can now only revoke the OAuth access to the entire GitHub CLI, which means I have to re-enable the CLI OAuth and re-login to all other devices.

  9. babakks commented on Aug 6, 2025

    @babakks
    Member

    No worries, @TonyXiang8787! 🍻

    I actually followed up with the stakeholders through internal comms to see if there's any ongoing/planned effort. Unfortunately, as of now, there are no such plans.

    So, I'm going to mark this issue as blocked and platform Problems with the GitHub platform rather than the CLI client to indicate that this is pending on platform changes.

    For the team: Although this is not necessarily related to gh auth commands, but I stamped the gh-auth relating to the gh auth command label to add more visibility to this issue when we're looking for auth related issues.

  10. added
    platform
    gh-auth
    and removed
    more-info-needed
    on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

blockedenhancementgh-authneeds-triageplatform

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions