software engineering3 min read

GitHub CLI: Opt in to expiring, auto-refreshing OAuth tokens

8 similar posts
  • GitHub CLI
  • Git
  • GitHub Enterprise Server

AI Summary

GitHub CLI now supports expiring, automatically refreshing OAuth credentials during a public preview. By passing the --expiring flag during login or configuring global settings, developers can use short-lived access tokens backed by rotating refresh tokens to improve security. The system integrates with Git via credential helper configurations and gracefully falls back to nonexpiring tokens if servers do not support them. While scripts capturing static tokens may break, background handling maintains smooth developer workflows.

Key Takeaways

  • Introduced in GitHub CLI v2.103.0 as a public preview feature.
  • Requires Git 2.46 or newer for optimal credential lifetime handling.
  • Will eventually become the default behavior for new sign-ins.

Why it matters

Expiring OAuth credentials significantly reduce the security blast radius of leaked tokens by transitioning from indefinite lifetimes to short-lived, automatically refreshing tokens managed via GitHub CLI.

Conversation0

What would you add from your experience?

Checking your session…

Every good conversation starts with one perspective.