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
Document minimum required v2 fine grain PAT scopes in gh auth login #9461
Describe the feature or problem you’d like to solve
The GitHub CLI predates the introduction of fine grained PATs. While we generally recommend users authenticate using the GitHub CLI OAuth app, we understand our users might prefer this alternative.
The gh auth login help docs explain the minimum required permission scopes for v1 coarse grain PATs, however it has no information about exactly which v2 scopes are needed to use the majority of gh commands.
Proposed solution
I propose the GitHub CLI exercises the various gh commands and document the minimum required v2 permission scopes needed to use gh without unexpected errors.
Describe the feature or problem you’d like to solve
The GitHub CLI predates the introduction of fine grained PATs. While we generally recommend users authenticate using the GitHub CLI OAuth app, we understand our users might prefer this alternative.
The gh auth login help docs explain the minimum required permission scopes for v1 coarse grain PATs, however it has no information about exactly which v2 scopes are needed to use the majority of gh commands.
Proposed solution
I propose the GitHub CLI exercises the various gh commands and document the minimum required v2 permission scopes needed to use gh without unexpected errors.
hey @andyfeller , where can i find the repo for these docs?(i have written the updated docs for this issue)
gh auth login
Authenticate with a GitHub host.
Usage
gh auth login [flags]
Description
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.
For classic personal access tokens, the minimum required scopes are: repo, read:org, and gist.
For fine-grained personal access tokens, the following permissions are typically required for full functionality:
Repository permissions:
Actions: Read and write
Administration: Read and write
Contents: Read and write
Environments: Read and write
Issues: Read and write
Metadata: Read-only (automatically added)
Pull requests: Read and write
Workflows: Read and write
Organization permissions:
Members: Read-only
Account permissions:
Gists: Read and write
Note: Specific gh commands may require fewer permissions. Refer to our online documentation for detailed permission requirements per command.
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.
Specifying ssh for the git protocol will detect existing SSH keys to upload, prompting to create and upload a new key if one is not found. This can be skipped with --skip-ssh-key flag.
Options
Flag
Description
-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
--skip-ssh-key
Skip generate/upload SSH key prompt
-w, --web
Open a browser to authenticate
--with-token
Read token from standard input
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 a fine-grained PAT
$ gh auth login --with-token
# Authenticate with a specific host
$ gh auth login --hostname enterprise.internal
Activity
aryanbhosale commentedon Aug 25, 2024
hey @andyfeller , where can i find the repo for these docs?(i have written the updated docs for this issue)
gh auth login
Authenticate with a GitHub host.
Usage
Description
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 statusfor its stored location.Alternatively, use
--with-tokento pass in a token on standard input.For classic personal access tokens, the minimum required scopes are:
repo,read:org, andgist.For fine-grained personal access tokens, the following permissions are typically required for full functionality:
Note: Specific gh commands may require fewer permissions. Refer to our online documentation for detailed permission requirements per command.
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 environmentfor more info.To use gh in GitHub Actions, add
GH_TOKEN: ${{ github.token }}toenv.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.Specifying
sshfor the git protocol will detect existing SSH keys to upload, prompting to create and upload a new key if one is not found. This can be skipped with--skip-ssh-keyflag.Options
-p,--git-protocol <string>-h,--hostname <string>--insecure-storage-s,--scopes <strings>--skip-ssh-key-w,--web--with-tokenExamples
See Also