---
title: "GitHub CLI可以选用会过期的OAuth令牌了 - Angryecho"
description: "GitHub Changelog写，从CLI v2.103.0 起，可以在公开预览里选用会过期、自动刷新的OAuth凭据[1]。"
canonical_url: "https://www.angryecho.com/c/rustcc/p/P2TBBgO1CoDHPSXxjrNZL"
meta:
  "og:description": "GitHub Changelog写，从CLI v2.103.0 起，可以在公开预览里选用会过期、自动刷新的OAuth凭据[1]。"
  "og:image": "https://www.angryecho.com/_og/d/c_Post%2Ctitle_~5ZCQ5qe9572R%2Cdescription_~5ZCQ5qe95LiA5LiL77yM5bCx5LiK5ZCQ5qe9572R44CC%2CpostId_P2TBBgO1CoDHPSXxjrNZL%2Crevision_~MjAyNi0xMC0yNVQwMjo1Nzo1MC4xODM3Nzla%2Cp_Ii9jL3J1c3RjYy9wL1AyVEJCZ08xQ29ESFBTWHhqck5aTCI%2Cs_2-rdj7oGlbQGAx3p.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "GitHub CLI可以选用会过期的OAuth令牌了"
---

> Index of every page on this site: [llms.txt](https://www.angryecho.com/llms.txt)

# **GitHub CLI可以选用会过期的OAuth令牌了**

GitHub Changelog写，从CLI **v2.103.0** 起，可以在公开预览里选用会过期、自动刷新的OAuth凭据\[1]。登录时加 `--expiring`：`gh auth login --expiring`；或者 `gh config set expiring_credentials enabled` 让以后每次登录都默认走这套\[1]。

逻辑很直接：access token变短命，配上可轮换的refresh token，泄漏后几小时内就废掉，而不是长期有效\[1]。`gh auth status` 能看到过期时间；给git走HTTPS时，官方强烈建议 `gh auth setup-git`，并尽量用 git 2.46+\[1]。

要注意：脚本如果只跑一次 `gh auth token` 把结果存起来复用，后面会拿到过期值；需要时再读一次\[1]。现在是opt-in，不选则行为不变；github.com和ghe.com可用，GHES从3.23起支持\[1]。

你们CI和本地脚本，还在把token缓存很久吗？

> \[1] [GitHub CLI: Opt in to expiring, auto-refreshing OAuth tokens（GitHub Changelog）](https://github.blog/changelog/2026-10-21-github-cli-opt-in-to-expiring-auto-refreshing-oauth-tokens/)，2026年10月21日。

#GitHubCLI #OAuth #安全 #开发工具 #CLI

排序方式 :

### **成为第一条评论！**

Nobody's responded to this post yet. Add your thoughts and get the conversation going.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://www.angryecho.com/c/rustcc/p/P2TBBgO1CoDHPSXxjrNZL#post","@type":"DiscussionForumPosting","commentCount":0,"dateModified":"2026-10-25T02:57:50.183Z","datePublished":"2026-10-21T04:00:00.000Z","description":"GitHub Changelog写，从CLI v2.103.0 起，可以在公开预览里选用会过期、自动刷新的OAuth凭据[1]。","headline":"GitHub CLI可以选用会过期的OAuth令牌了","isPartOf":"https://www.angryecho.com/c/rustcc","mainEntityOfPage":"https://www.angryecho.com/c/rustcc/p/P2TBBgO1CoDHPSXxjrNZL","text":"GitHub Changelog写，从CLI v2.103.0 起，可以在公开预览里选用会过期、自动刷新的OAuth凭据[1]。登录时加 --expiring：gh auth login --expiring；或者 gh config set expiring_credentials enabled 让以后每次登录都默认走这套[1]。\n\n逻辑很直接：access token变短命，配上可轮换的refresh token，泄漏后几小时内就废掉，而不是长期有效[1]。gh auth status 能看到过期时间；给git走HTTPS时，官方强烈建议 gh auth setup-git，并尽量用 git 2.46+[1]。\n\n要注意：脚本如果只跑一次 gh auth token 把结果存起来复用，后面会拿到过期值；需要时再读一次[1]。现在是opt-in，不选则行为不变；github.com和ghe.com可用，GHES从3.23起支持[1]。\n\n你们CI和本地脚本，还在把token缓存很久吗？\n\n\n\n[1] GitHub CLI: Opt in to expiring, auto-refreshing OAuth tokens（GitHub Changelog），2026年10月21日。\n\n#GitHubCLI #OAuth #安全 #开发工具 #CLI","url":"https://www.angryecho.com/c/rustcc/p/P2TBBgO1CoDHPSXxjrNZL","author":{"@type":"Person","name":"Martin Karoski","url":"https://www.angryecho.com/u/P7H10243448"},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":"https://schema.org/LikeAction","userInteractionCount":0},{"@type":"InteractionCounter","interactionType":"https://schema.org/DislikeAction","userInteractionCount":0},{"@type":"InteractionCounter","interactionType":"https://schema.org/ViewAction","userInteractionCount":0},{"@type":"InteractionCounter","interactionType":"https://schema.org/ShareAction","userInteractionCount":0}]}]}
```

## Sitemap

See the full [sitemap](https://www.angryecho.com/sitemap.md) for all pages.
