Git 凭据管理器 (GCM) 如何在不手动创建个人访问令牌 (PAT) 的情况下工作?

How does Git Credential Manager (GCM) work without manually creating a Personal access tokens (PAT)?

我在网上搜索过,没有找到明确的答案,所以也许这里有人可以帮助我理解。

总结问题

Git Credential Manager (GCM) is another way to store your credentials securely and connect to GitHub over HTTPS. With GCM, you don't have to manually create and store a PAT, as GCM manages authentication on your behalf, including 2FA (two-factor authentication).

If you authenticate without GitHub CLI, you must authenticate with a personal access token. When Git prompts you for your password, enter your personal access token (PAT) instead. Password-based authentication for Git has been removed, and using a PAT is more secure. For more information, see "Creating a personal access token." Every time you use Git to authenticate with GitHub, you'll be prompted to enter your credentials to authenticate with GitHub, unless you cache them a credential helper.

我对上面的粗线很感兴趣:

GCM(核心)如何代表我“管理”身份验证而无需我必须手动创建 PAT?

我尽量让问题简短而准确,但我会在这里稍微详细说明一下: 我尝试将 GIT 用于 Windows(最新版本)以及 VS 2022 附带的 GIT。两者都是最新的并使用 [=66= 的最新版本]Credential Manager Core,这是 GitHub 的新(自 2021 年起)政策所必需的,不再允许 acc/pw 并且身份验证现在需要使用 PAT。 但是 我想知道 GCM 实际上是如何 神奇地 工作的,而无需在 GitHub 设置中手动创建 PAT(参见链接)。从提到的文章中,我强烈假设 Windows 凭据管理器持有某种访问令牌(或者甚至 acc/pw???)。我希望能找到一些关于这方面的说明。

- acc/pw 是存储在 Windows 凭据管理器(以前称为 Vault)中还是令牌? -令牌来自哪里,如果不是由用户在 GitHub 中手动创建(是否有来自 GitHub 的 api/webservice 可能被 GCM 调用???如果是这样,为什么要这样做这些教程指示手动添加 PAT???我如何才能利用相同的功能???)

旁注:

我搜索的其他来源:

Creating a personal access token

Authenticate with GitHub using a token

Support for password authentication was removed. Please use a personal access token instead

仅更多提及手动创建的 PAT...(恰恰相反,与所问的相反)

Authenticate with GitHub using a token

Support for password authentication was removed. Please use a personal access token instead

非常感谢大家!

GitHub 个人访问令牌只是 GitHub OAuth 令牌的一个特例。我不记得当前的 GCM Core 实现是如何工作的,因为我认为它已经从 pre-Core GCM 实现中改变了,但它基本上让你登录并执行某种 OAuth 流程来为你发布令牌帐户。无论是实际的 PAT 还是不同类型的 OAuth 令牌都无关紧要,因为它们本质上是一样的。

GCM Core 可以将凭据存储在多个位置,包括系统凭据存储(因操作系统而异)。一旦它们被存储,Git 将在它们有效时使用它们。

大多数教程建议自己生成 PAT 的原因是因为 GCM Core 虽然可用于多个平台,但默认情况下不会在任何地方提供,除了作为 Git for Windows 的一部分。事实上,因为它是用 .NET 编写的,让它在 macOS 和 Linux 上运行通常有点麻烦,因此通常使用其他凭证助手。有些人还在 Windows 上使用不同的凭据管理器。大多数编写教程的人都希望提出普遍适用的建议,因此建议 PAT 是让人们起来的简单易行的方法 运行.

如果你想做类似的事情来发行代币,GitHub provides documentation on how to do that with OAuth apps。这些令牌,取决于用户授予的权限,如果需要,也可用于访问 API。