
Goodbye to everlasting tokens! GitHub CLI tests credentials that renew themselves
GitHub CLI now lets users sign in with short-lived OAuth tokens that refresh automatically. The opt-in preview is available starting with GitHub CLI 2.103.0. The change shortens the exposure window for leaked credentials, though scripts that store tokens for long-term reuse may need adjustments. For DevOps teams, it is a concrete improvement in day-to-day identity management.
Persistent authentication comes at a security cost. Many developers keep access credentials for long periods to avoid signing in repeatedly. When a token is accidentally leaked in a log, script or file, it can remain useful to an attacker until someone revokes it. GitHub aims to reduce that risk with expiring access tokens and rotating refresh credentials.
The option can already be tested. Starting with GitHub CLI 2.103.0, the gh auth login --expiring command requests this scheme. It can also be enabled by default with gh config set expiring_credentials enabled. GitHub recommends running gh auth setup-git if Git uses HTTPS and upgrading to Git 2.46 or later to prevent credentials from being stored longer than they should. The feature is still optional and compatible with the previous sign-in method. Workflows that copy the output of gh auth token once will need to be adapted to request an updated token when they need it.


