Merge pull request #2057 from cli/auth-scopes-doc

Specify minimum required token scopes in `gh help auth login`
This commit is contained in:
Nate Smith 2020-10-05 16:00:25 -05:00 committed by GitHub
commit edec480b34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,22 +43,23 @@ func NewCmdLogin(f *cmdutil.Factory, runF func(*LoginOptions) error) *cobra.Comm
Use: "login",
Args: cobra.ExactArgs(0),
Short: "Authenticate with a GitHub host",
Long: heredoc.Doc(`Authenticate with a GitHub host.
Long: heredoc.Docf(`
Authenticate with a GitHub host.
This interactive command initializes your authentication state either by helping you log into
GitHub via browser-based OAuth or by accepting a Personal Access Token.
The default authentication mode is a web-based browser flow.
The interactivity can be avoided by specifying --with-token and passing a token on STDIN.
`),
Alternatively, pass in a token on standard input by using %[1]s--with-token%[1]s.
The minimum required scopes for the token are: "repo", "read:org".
`, "`"),
Example: heredoc.Doc(`
# start interactive setup
$ gh auth login
# => do an interactive setup
# authenticate against github.com by reading the token from a file
$ gh auth login --with-token < mytoken.txt
# => read token from mytoken.txt and authenticate against github.com
$ gh auth login --hostname enterprise.internal --with-token < mytoken.txt
# => read token from mytoken.txt and authenticate against a GitHub Enterprise Server instance
# authenticate with a specific GitHub Enterprise Server instance
$ gh auth login --hostname enterprise.internal
`),
RunE: func(cmd *cobra.Command, args []string) error {
if !opts.IO.CanPrompt() && !(tokenStdin || opts.Web) {