> 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 凭据进行身份验证。本页面将引导您完成配置过程。

## 配置 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 系统将 Google 唯一 ID 存储在 VergeOS 用户记录中（在使用“远程用户字段”中定义的字段最初定位 Google 用户之后），这样以后就可以使用该唯一标识符来查找 Google 用户；通常建议这样做，因为电子邮件地址等字段可能会更改。**
{% endhint %}

11. **其他可选字段** 参见 [**授权源 - 概览**](https://github.com/verge-io/docs-vergeos/tree/main/run/product-guide/auth/auth-sources-overview.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
