Skip to content

Include the codespace scope by default with gh auth login #6047

@jkeech

Description

@jkeech

Describe the feature or problem you’d like to solve

In order to make interacting with codespaces easier using the CLI, I'd like the scopes included in gh auth login to include the codespace scope by default, or alternatively, to have the gh auth login have an interactive flow where it prompts for the set of scopes that the user wants to login with.

This will prevent users from signing in with the default gh auth login, then trying to use the gh codespace commands only to realize they need to refresh the login to add a codespace scope with gh auth refresh -s codespace before retrying the gh codespace commands.

Proposed solution

  1. gh auth login includes the codespace scope by default OR
  2. gh auth login prompts the user for the set of scopes that they would like to include as part of the initial login.

How will it benefit CLI and its users? Less friction when setting up gh on a new machine.

Current experience having to do the auth flow twice when selecting the defaults:

~ » gh codespace list                                                                                               
To get started with GitHub CLI, please run:  gh auth login
Alternatively, populate the GH_TOKEN environment variable with a GitHub API authentication token.
---------------------------------------------------------------------------------------------------------------------------------------
~ » gh auth login                                                                                                
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: EAEA-B5EF
Press Enter to open github.com in your browser... 
✓ Authentication complete.
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as jkeech
---------------------------------------------------------------------------------------------------------------------------------------
~ » gh codespace list                                                                                               
error getting codespaces: HTTP 403: Must have admin rights to Repository. (https://api.github.com/user/codespaces?per_page=30)
This API operation needs the "codespace" scope. To request it, run:  gh auth refresh -h github.com -s codespace
---------------------------------------------------------------------------------------------------------------------------------------
~ » gh auth refresh -h github.com -s codespace                                                                 
? Authenticate Git with your GitHub credentials? Yes

! First copy your one-time code: 3B81-697C
Press Enter to open github.com in your browser... 
✓ Authentication complete.
---------------------------------------------------------------------------------------------------------------------------------------
~ » gh codespace list   

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussFeature changes that require discussion primarily among the GitHub CLI teamenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions