Difference between revisions of "Gh auth login"

From wikieduonline
Jump to navigation Jump to search
Line 2: Line 2:
 
  [[gh auth]] login <ref>https://cli.github.com/manual/gh_auth_login</ref>
 
  [[gh auth]] login <ref>https://cli.github.com/manual/gh_auth_login</ref>
 
  [[gh auth status]]
 
  [[gh auth status]]
 +
 +
== Help ==
 +
<pre>
 +
gh auth login --help
 +
Authenticate with a GitHub host.
 +
 +
The default authentication mode is a web-based browser flow. After completion, an
 +
authentication token will be stored securely in the system credential store.
 +
If a credential store is not found or there is an issue using it gh will fallback
 +
to writing the token to a plain text file. See `gh auth status` for its
 +
stored location.
 +
 +
Alternatively, use `--with-token` to pass in a token on standard input.
 +
The minimum required scopes for the token are: `repo`, `read:org`, and `gist`.
 +
 +
Alternatively, gh will use the authentication token found in environment variables.
 +
This method is most suitable for "headless" use of gh such as in automation. See
 +
`gh help environment` for more info.
 +
 +
To use gh in GitHub Actions, add `GH_TOKEN: ${{ github.token }}` to `env`.
 +
 +
The git protocol to use for git operations on this host can be set with `--git-protocol`,
 +
or during the interactive prompting. Although login is for a single account on a host, setting
 +
the git protocol will take effect for all users on the host.
 +
 +
 +
USAGE
 +
  gh auth login [flags]
 +
 +
FLAGS
 +
  -p, --git-protocol string  The protocol to use for git operations on this host: {ssh|https}
 +
  -h, --hostname string      The hostname of the GitHub instance to authenticate with
 +
      --insecure-storage      Save authentication credentials in plain text instead of credential store
 +
  -s, --scopes strings        Additional authentication scopes to request
 +
  -w, --web                  Open a browser to authenticate
 +
      --with-token            Read token from standard input
 +
 +
INHERITED FLAGS
 +
  --help  Show help for command
 +
 +
EXAMPLES
 +
  # Start interactive setup
 +
  $ gh auth login
 +
 +
  # Authenticate against github.com by reading the token from a file
 +
  $ gh auth login --with-token < mytoken.txt
 +
 +
  # Authenticate with specific host
 +
  $ gh auth login --hostname enterprise.internal
 +
 +
LEARN MORE
 +
  Use `gh <command> <subcommand> --help` for more information about a command.
 +
  Read the manual at https://cli.github.com/manual
 +
</pre>
  
 
== Examples ==
 
== Examples ==

Revision as of 19:54, 7 February 2024

gh auth login [1]
gh auth status

Help

gh auth login --help
Authenticate with a GitHub host.

The default authentication mode is a web-based browser flow. After completion, an
authentication token will be stored securely in the system credential store.
If a credential store is not found or there is an issue using it gh will fallback
to writing the token to a plain text file. See `gh auth status` for its
stored location.

Alternatively, use `--with-token` to pass in a token on standard input.
The minimum required scopes for the token are: `repo`, `read:org`, and `gist`.

Alternatively, gh will use the authentication token found in environment variables.
This method is most suitable for "headless" use of gh such as in automation. See
`gh help environment` for more info.

To use gh in GitHub Actions, add `GH_TOKEN: ${{ github.token }}` to `env`.

The git protocol to use for git operations on this host can be set with `--git-protocol`,
or during the interactive prompting. Although login is for a single account on a host, setting
the git protocol will take effect for all users on the host.


USAGE
  gh auth login [flags]

FLAGS
  -p, --git-protocol string   The protocol to use for git operations on this host: {ssh|https}
  -h, --hostname string       The hostname of the GitHub instance to authenticate with
      --insecure-storage      Save authentication credentials in plain text instead of credential store
  -s, --scopes strings        Additional authentication scopes to request
  -w, --web                   Open a browser to authenticate
      --with-token            Read token from standard input

INHERITED FLAGS
  --help   Show help for command

EXAMPLES
  # Start interactive setup
  $ gh auth login

  # Authenticate against github.com by reading the token from a file
  $ gh auth login --with-token < mytoken.txt

  # Authenticate with specific host
  $ gh auth login --hostname enterprise.internal

LEARN MORE
  Use `gh <command> <subcommand> --help` for more information about a command.
  Read the manual at https://cli.github.com/manual

Examples

 ? What account do you want to log into? GitHub Enterprise Server
? GHE hostname: github.youthostname.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? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.yourname.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow' (GHE 3.0+).
? Paste your authentication token: ***********************
- gh config set -h github.yourname git_protocol https
✓ Configured git protocol
✓ Logged in as youruser


? What account do you want to log into?  [Use arrows to move, type to filter]
> GitHub.com
  GitHub Enterprise Server

> HTTPS
  SSH

! First copy your one-time code: 8A0V-XXYY
- Press Enter to open github.com in your browser...
✓ Authentication complete. Press Enter to continue...

- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
HTTP 422: Validation Failed (https://api.github.com/user/keys)
key is already in use

Related

See also

  • https://cli.github.com/manual/gh_auth_login
  • Advertising: