> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/run-the-platform/zh/shen-fen-yan-zheng/google-auth.md).

# 使用 Google 进行身份验证

在 VergeOS 中将 Google 配置为 OAuth2 授权源的分步指南，包括获取凭据和创建用户。

VergeOS 可以配置为允许用户使用其企业 Google 凭据进行身份验证。本页将引导您完成配置过程。

## 配置 Google 授权源

1. 获取 **客户端 ID** 和 **客户端密钥** 来自 Google 系统。这些值应根据 VergeOS 系统的公共 URL 生成。有关说明，请参阅 Google 文档，例如 [**https://developers.google.com/identity/protocols/oauth2**](https://developers.google.com/identity/protocols/oauth2)

{% hint style="success" %}
客户端 ID 和密钥通常可在以下位置生成： [***https://console.developers.google.com***](https://console.developers.google.com/)
{% endhint %}

2. 点击 **系统** 在顶部菜单中。
3. 选择 **身份验证源**.
4. 点击 **新建** 在左侧菜单中。
5. 输入 ***名称*** 作为该来源的名称（例如“Google”）。此名称将显示在 VergeOS 登录页面的登录按钮上。
6. 在 ***驱动程序*** 字段（下拉列表）中，选择 **Google**.
7. ***重定向 URI*** 应填写为 VergeOS 系统的 URL。这必须是可被 Google API 访问的公共地址。
8. 输入 ***客户端 ID*** 和 ***客户端密钥*** 从 Google 获取的值。
9. ***远程用户字段*** 是用于最初查找 Google 用户的字段列表；此字段会自动填充为（sub,preferred\_username,email nickname），这是一个通常可用于 Google 实现的默认列表。 **注意：出于安全原因，不建议基于远程系统上可由最终用户更改的字段来定位远程用户。**
10. **选项（建议启用这些选项。）**
    * ***更新远程用户：*** - 一旦在 Google 系统中找到用户，更新 VergeOS 用户 *远程用户名* 字段为对应的 Google 唯一 ID（sub 字符串）
    * **更新用户电子邮件地址：** - 将 VergeOS 用户电子邮件地址更新为与 Google 中的电子邮件地址一致。
    * **更新用户显示名称：** - 将 VergeOS 用户显示名称更新为与 Google 中的显示名称一致。

{% hint style="success" %}
**启用&#x20;*****更新远程用户*****&#x20;字段将允许 VergeOS 系统在 VergeOS 用户记录中存储唯一的 Google ID（在使用“远程用户字段”中定义的字段最初定位 Google 用户之后），因此随后可以使用该唯一标识符来查找 Google 用户；通常建议这样做，因为诸如电子邮件地址之类的字段可能会更改。**
{% endhint %}

11. **其他可选字段** 请参阅 [**授权源 - 概述**](https://docs.verge.io/run-the-platform/zh/shen-fen-yan-zheng/auth-sources-general.md) 以了解有关其他可选字段的信息。
12. 完成配置后，点击 **提交** 以保存新的授权源。

## 添加将使用 Google 身份验证的 VergeOS 用户

创建授权源后，可以创建用户以使用 Google 源登录。 **按以下配置创建新的 VergeOS 用户：**

* ***授权源：*** 从下拉列表中选择 Google 源
* ***用户名：*** VergeOS 系统中的唯一名称；通常建议使用与 Google 中相同的登录名。
* ***远程用户名：*** 使用定义为远程用户字段之一的值，这些字段是在 Google 中搜索的字段；用户电子邮件地址或 sub 字符串（相当于用户的 Google ID）通常是最佳选择。
* ***显示名称：*** （可选）如果 *更新用户显示名称* 在 Google 身份验证源上已启用，则显示名称将与 Google 用户同步。
* ***电子邮件地址：*** （可选）如果 *更新用户电子邮件地址* 在 Google 身份验证源上已启用，则电子邮件地址将与 Google 用户同步。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.verge.io/run-the-platform/zh/shen-fen-yan-zheng/google-auth.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
