Skip to content

print url for authentication #612

Description

@trondhindenes

as many others, I have one private github account, and another for work. Since github doesn't really allow easy account switching, i'm using one browser for my private stuff, and another browser for my work stuff.

This means that I need to be able to select which browser to use for gh authentication setup. It currently just opens the default browser.

My ask is that gh instead prints out the auth url, so that I can open it in the browser of my choosing. This would work much better for folks with multiple github accounts linked to different browsers.

Activity

  1. mislav commented on Mar 9, 2020

    @mislav
    Contributor

    Thanks for detailing your use case! You can set the BROWSER environment variable right now. Is this be a good enough workaround for you?

    BROWSER='open -a Safari' gh ...
  2. xloem commented on Apr 9, 2020

    @xloem

    I'm having a related issue of trying to use the tool in a headless environment (but with firefox running on the same account, elsewhere), and I set BROWSER=elinks, but the tool still just hangs there after I hit enter.

    EDIT: When I set BROWSER=nonexistent it outputs the needed url. Seems to be the answer.

  3. added
    authrelated to tokens, authentication state, or oauth
    on Aug 13, 2020
  4. vilmibm commented on Aug 13, 2020

    @vilmibm
    Contributor

    @ampinsk @mislav is this something we should consider, still? while we've greatly improved the auth experience at no point do we print out the URL for the browser flow unless things fail in a specific way.

    I'm wondering if it's worth printing out in the "Press enter to open hostname in your browser" message instead of hostname during the browser flow.

  5. ampinsk commented on Aug 13, 2020

    @ampinsk

    @vilmibm I think that would be a nice improvement!

  6. vilmibm commented on Aug 31, 2020

    @vilmibm
    Contributor

    We've decided to close this. The pain of having to manage two separate GitHub accounts is real, but after discussing internally we think the best solution right now is to rely on the BROWSER environment variable since that will select the appropriate browser for things like auth login as well as repo view -w.

    An improvement that I'd welcome, however, is having a config setting for browser which could be set per host. If there's interest in that we can open an issue for it.

  7. shibaeff commented on Apr 23, 2026

    @shibaeff

    after discussing internally

    are you guys all frontend developers and management? 90% of devops engineers work in headless setups, so this feature is a must

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

    authrelated to tokens, authentication state, or oauthenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions