Skip to content

Authenticate without a manually-created token and without a browser #14089

Open

Description

@ArnoGW1

Describe the feature or problem you’d like to solve

In WSL2, gh auth login opens a CLI browser that can't handle the GitHub device login page. Ctrl+C quits the command and stops the login flow.

There's a workaround where if you go to https://github.com/login/device first, paste the CLI's code there, and then let the CLI open the browser and quit it with q, login will succeed, but that's impractical.

PATs aren't a good solution because they take more effort: you have to go to the GitHub settings, pick the permissions, choose an expiry date, and do that again when they expire. They can't be short-lived without adding refresh burden, especially when working in multiple containers, machines, etc. The CLI login flow is better for that.

Proposed solution

Just gh auth login --no-browser. It prints the code and the login URL (https://github.com/login/device), then waits. Doesn't try to open a browser.

This is the fastest way to log into GitHub CLI without managing tokens by hand.

Additional context

This was closed due to the possibility of pasting a Personal Access Token, but that's not the same thing. You have to create and refresh them manually, you have to pick the permissions manually, they expire, etc.

Activity

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

    @cli-triage

    Caution

    agentic threat detected
    Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

    Details

    Potential security threats were detected in the agent output.

    Review the workflow run logs for details.

    Thanks for the suggestion! I'm classifying this as an enhancement and suggesting the enhancement and gh-auth labels, since it proposes a new --no-browser flag for gh auth login to skip the browser-open step and just print the device code/URL for manual/headless completion.

    This is closely related to prior discussions on headless/browser-less login (#5500 "Login with a web browser on headless machine", closed as completed) and other recent reports about SSH/WSL/headless auth UX, but it's not an exact duplicate — those focused on general headless detection or workarounds (e.g. GH_BROWSER=/bin/true), while this specifically proposes a documented --no-browser flag. A maintainer may want to confirm whether existing workarounds (like setting GH_BROWSER to a no-op command) already satisfy this need or whether a first-class flag is warranted.

    Generated by Issue Triage (skills-driven) for #14089 · auto · 25.2 AIC · ⌖ 1.64 AIC · ⊞ 9.2K · ◷

  3. williammartin commented on Aug 6, 2026

    @williammartin
    Member

    Hey @ArnoGW1, can you say a little bit more about:

    opens a CLI browser

    What does this actually mean? Can you take a screenshot?

  4. ArnoGW1 commented on Aug 6, 2026

    @ArnoGW1
    Author

    Hey @ArnoGW1, can you say a little bit more about:

    opens a CLI browser

    What does this actually mean? Can you take a screenshot?

    Image

    After hitting Enter (and validating a cookie prompt in the same browser):
    Image

    It's the Lynx browser. There might be a way to change the default, make it handle that page correctly, let gh open the Windows browser from WSL, etc. but that's not worth the effort compared to Ctrl+Click on the https://github.com/login/device URL in the prompt that gh shows.

  5. williammartin commented on Aug 6, 2026

    @williammartin
    Member

    Thanks. What happens if you do something like GH_BROWSER=wslview gh auth login?

  6. ArnoGW1 commented on Aug 6, 2026

    @ArnoGW1
    Author

    Thanks. What happens if you do something like GH_BROWSER=wslview gh auth login?

    Press Enter to open https://github.com/login/device in your browser...
    ! Failed opening a web browser at https://github.com/login/device
      exec: "wslview": executable file not found in $PATH
      Please try entering the URL in your browser manually
    

    If I Ctrl+click the URL and finish the login flow in my Windows browser, the CLI seems to require me to press Enter again to react to it, then login succeeds.

  7. williammartin commented on Aug 6, 2026

    @williammartin
    Member

    It think like it would be fine to support --no-browser generally, but it does seem like it would be easier if you one time set up a handler so that one of these providers is configured correctly: https://github.com/cli/browser/blob/main/browser_linux.go#L9 (or set GH_BROWSER to the path of your browser). Is there some reason you don't want to do that?

  8. a-gn commented on Aug 6, 2026

    @a-gn

    It think like it would be fine to support --no-browser generally, but it does seem like it would be easier if you one time set up a handler so that one of these providers is configured correctly: https://github.com/cli/browser/blob/main/browser_linux.go#L9 (or set GH_BROWSER to the path of your browser). Is there some reason you don't want to do that?

    (Same person, different account.) I change environments often at work so it wouldn't be one-time, it would be WSL on system 1, WSL on system 2, dev containers 1 to 10, etc. It would also be the systems of people on my team that I sometimes do support for and who have less experience with this.

    It would be much easier to be able to say "run gh auth login --no-browser, open the link, follow the forms and you're done" than to explain how to set up a browser handler.

    In general, I think it's better to support a simple, slightly more manual method than to force an automatic process that requires more reading and setup just to get past.

  9. added
    enhancement
    gh-auth
    on Aug 9, 2026
  10. removed
    needs-triage
    on Aug 9, 2026
  11. github-actions commented on Aug 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.

  12. babakks commented on Aug 9, 2026

    @babakks
    Member

    I like the idea of --no-browser flag, which should just print the URL and start polling for the token.

  13. babakks commented on Aug 9, 2026

    @babakks
    Member

    By the way, if you run auth login in non-tty mode (e.g. gh auth login |& cat) the browser path is not going to be taken.

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-authstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions