You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhance gh auth login to copy one-time code into clipboard before launching browser #11354
authrelated to tokens, authentication state, or oauthenhancementa request to improve CLIgh-authrelating to the gh auth commandhelp wantedContributions welcome
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:
Environment variable: GH_CLIPBOARD=1
Configuration setting: gh config set clipboard enabled
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:
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 wantedContributions 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.
Notes from internal meetings: we might want to include a message on stderr when there is a TTY indicating the availability of --clipboard for discoverability reasons. We also discussed adding a press c to copy alternative option to the press enter to open browser prompt, but will likely table that until it makes sense.
When a user authenticates with gh auth login --web --clipboard OR When a user authenticates with gh auth login --clipboard and selects Login with a web browser Thengh auth login will:
Write the one-time OAuth device code to the user's clipboard
Print a message on stderr telling the user that the one-time code has been stored in their clipboard such as:
One-time code copied to clipboard
When a user authenticates with gh auth login --web OR When a user authenticates with gh auth login and selects Login with a web browser Thengh auth login will display the existing First copy your one-time code message
Outside of scope
no environment variable of gh config setting to control this
no assumptions of whether this should change with interactive or non-interactive flows; users who provide this flag will get the behavior despite the modality
@BagToad : Perhaps outside the scope of this issue, but I can also see this being extended to gh auth refresh since a similar experience is present there:
$ gh auth refresh -s read:project
? What account do you want to refresh auth for? github.com
! First copy your one-time code: ###X-####
Press Enter to open https://github.com/login/device in your browser...
@BagToad : Perhaps outside the scope of this issue, but I can also see this being extended to gh auth refresh since a similar experience is present there:
$ gh auth refresh -s read:project
? What account do you want to refresh auth for? github.com
Right! Good call. I think we should make another issue, maybe a sub-issue? They might be closed by the same PR but in case they aren't then it would be good to have two issues.
authrelated to tokens, authentication state, or oauthenhancementa request to improve CLIgh-authrelating to the gh auth commandhelp wantedContributions welcome
Activity
github-actions commentedon Jul 21, 2025
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 wantedContributions 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.
summersdarius16-cmyk commentedon Jul 21, 2025
summersdarius16-cmyk commentedon Jul 21, 2025
BagToad commentedon Jul 28, 2025
Notes from internal meetings: we might want to include a message on stderr when there is a TTY indicating the availability of
--clipboardfor discoverability reasons. We also discussed adding apress c to copyalternative option to thepress enter to open browserprompt, but will likely table that until it makes sense.andyfeller commentedon Jul 28, 2025
Acceptance Criteria
When a user authenticates with
gh auth login --web --clipboardORWhen a user authenticates with
gh auth login --clipboardand selectsLogin with a web browserThen
gh auth loginwill:Write the one-time OAuth device code to the user's clipboard
Print a message on stderr telling the user that the one-time code has been stored in their clipboard such as:
When a user authenticates with
gh auth login --webORWhen a user authenticates with
gh auth loginand selectsLogin with a web browserThen
gh auth loginwill display the existingFirst copy your one-time codemessageOutside of scope
gh configsetting to control thisRelated code
cli/internal/authflow/flow.go
Lines 32 to 91 in 7d70980
andyfeller commentedon Jul 30, 2025
@BagToad : Perhaps outside the scope of this issue, but I can also see this being extended to
gh auth refreshsince a similar experience is present there:BagToad commentedon Jul 30, 2025
Right! Good call. I think we should make another issue, maybe a sub-issue? They might be closed by the same PR but in case they aren't then it would be good to have two issues.
BagToad commentedon Aug 25, 2025
NOTE: the closing PR #11518 implements
gh auth loginandgh auth refresh