GitHub CLI 2.103.0
New 3
gh can sign in with auto-refreshing credentials (preview)
Normally, signing in to GitHub with gh gives you a token (the pass that proves who you are) that never expires. You can now opt into expiring OAuth credentials instead: gh stores a short-lived access token alongside a rotating refresh token (a credential used only to get a new pass). The access token is refreshed automatically whenever needed, so you stay signed in without authenticating again. ⟦An office swapped its permanent badges for temporary ones reissued every day: you used to keep one badge until you left the company, and now it renews daily while you still just tap in each morning.⟧ This is a preview you have to opt into. To use it for a single sign-in, run:
```shell gh auth login --expiring ```
To prefer expiring credentials for every sign-in, run:
```shell gh config set expiring_credentials enabled ```
Original changelog
## Expiring, auto-refreshing OAuth tokens (preview)
gh can now sign in with expiring OAuth credentials that it refreshes automatically. When you opt in, gh stores a short-lived access token alongside a rotating refresh token and refreshes the access token whenever it is needed, so you stay signed in without having to authenticate again.
To opt in for a single sign-in, run:
```shell
gh auth login --expiring
```
To prefer expiring credentials for every sign-in, run:
```shell
gh config set expiring_credentials enabled
```
Living with expiring gh credentials: status, git and scripts
Once expiring credentials are on, you may want to know how long yours has left. gh auth status shows whether a credential is refreshable and when the current access token expires, and both gh auth status and gh auth token refresh the access token automatically when needed. Expiring tokens are available on github.com and GHE.com; on hosts that do not issue them, gh falls back to a regular non-expiring token. If git talks to GitHub over HTTPS, the advice is to use git 2.46 or newer and run gh auth setup-git so gh acts as git's credential helper (the program that hands git its sign-in details). That way git does not cache the credential past its lifetime. ⟦Treat it like fresh milk: you could once stock up a crate and drink it slowly, and now you buy it as you need it.⟧ So scripts and extensions should not store the output of gh auth token; run it again each time a token is needed. Tokens supplied through GH_TOKEN or GITHUB_TOKEN are never refreshed.
Original changelog
gh auth status shows whether a credential is refreshable and when the current access token expires. Both gh auth status and gh auth token automatically refresh the access token when needed. Expiring tokens are available on github.com and GHE.com; on hosts that do not issue them, gh falls back to a regular non-expiring token.
If you use HTTPS as your git protocol, we advise using git 2.46 or newer and letting gh act as your git credential helper by running gh auth setup-git. This way gh serves and refreshes the expiring credential for git, and git does not cache it past its lifetime.
> [!IMPORTANT]
> Expiring access tokens should not be cached. Scripts and extensions that store the output of gh auth token will eventually hold an expired token, so run gh auth token again each time a token is needed. Tokens supplied through GH_TOKEN or GITHUB_TOKEN are never refreshed.
For more information, see [Authenticating with GitHub CLI](https://docs.github.com/github-cli/github-cli/authenticating-with-github-cli#using-expiring-refreshable-tokens).
New gh issue artifact manages issue artifacts from the terminal (private preview)
When planning a new feature, you may want to hang the plan, a flow chart or a web prototype right on a GitHub issue (the thread that tracks a task or problem). gh issue artifact brings issue artifacts to the command line with six commands, list, view, create, edit, download and delete, for example:
```shell # Create a Markdown document with an attached image gh issue artifact create 142 signin-plan.md --attach ./signin-flow.png
# Create an HTML document gh issue artifact create 142 menu-prototype.html
# List or view artifacts gh issue artifact list 142 gh issue artifact view 142 2
# Update a document or restore an earlier version gh issue artifact edit 142 2 --body-file signin-plan-v2.md gh issue artifact edit 142 2 --restore-version 5 ```
⟦Give every work ticket its own folder that holds the plan and the prototype and remembers every version, so rolling back to version 5 is easy.⟧ Artifacts can also be addressed by their GitHub URLs, and Markdown documents take image and video attachments with --attach. This is a private preview: only users and organizations enrolled can use it, and the commands work only for repositories in the preview; access instructions are in the official preview announcement discussion.
Original changelog
## Manage issue artifacts with gh issue artifact (private preview)
gh issue artifact brings issue artifacts to the command line. Users and organizations enrolled in the private preview can use the list, view, create, edit, download, and delete commands to manage issue artifacts.
```shell
# Create a Markdown document with an attached image
gh issue artifact create 142 signin-plan.md --attach ./signin-flow.png
# Create an HTML document
gh issue artifact create 142 menu-prototype.html
# List or view artifacts
gh issue artifact list 142
gh issue artifact view 142 2
# Update a document or restore an earlier version
gh issue artifact edit 142 2 --body-file signin-plan-v2.md
gh issue artifact edit 142 2 --restore-version 5
```
Artifacts can also be addressed by their GitHub URLs, and Markdown documents support image and video attachments with --attach.
> [!IMPORTANT]
> Issue artifacts are in private preview. These commands only work for repositories enrolled in the preview. See the [Issue Artifacts private preview announcement and feedback discussion](https://github.com/orgs/community/discussions/205881) for access instructions and to share feedback.