Skip to content

Enhance gh auth login to copy one-time code into clipboard before launching browser #11354

@andyfeller

Description

@andyfeller

Describe the feature or problem you’d like to solve

When I use gh auth login to login with the GitHub CLI OAuth app, I have to manually select and copy the one-time device code before launching the browser so I can paste it into the GitHub.com device login screen.

! First copy your one-time code: 7701-C5F6
Press Enter to open https://github.com/login/device in your browser... 

I'd like some way I can configure gh to use the clipboard for certain features like gh auth login.

Proposed solution

I can see 3 different ways to provide this ability depending on how broadly this capability might be extended:

  1. Environment variable: GH_CLIPBOARD=1
  2. Configuration setting: gh config set clipboard enabled
  3. Command-specific flag: gh auth login --clipboard

Additional context

One of gh dependencies is already including a library for putting content into the system's copy buffer:

cli/go.mod

Line 73 in 42a8e02

github.com/atotto/clipboard v0.1.4 // indirect

Metadata

Metadata

Assignees

No one assigned

    Labels

    authrelated to tokens, authentication state, or oauthenhancementa request to improve CLIgh-authrelating to the gh auth commandhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions