> For the complete documentation index, see [llms.txt](https://doc.duaer.com/zh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/integrations/builtin/credentials/google.md).

# 在 Duaer 里配置 Google 凭证

在 Duaer 中保存 Google 的连接信息，供工作流程节点在运行时使用。密钥经实例加密密钥保护，不会写进节点参数。
## 获取 Gemini API 密钥 <a href="#get-a-gemini-api-key" id="get-a-gemini-api-key"></a>

Duaer 的 Google Gemini(PaLM) Api 凭证用 Google AI Studio 的 API 密钥：

1. 登录 [Google AI Studio](https://aistudio.google.com/apikey)，点 Create API key，选一个 Google Cloud 项目。
2. 复制密钥，在 Duaer 里新建 Google Gemini(PaLM) Api 凭证，粘到 API Key。
3. Host 保持默认的 https://generativelanguage.googleapis.com，只在走代理时修改。

这一页的 Google Workspace Admin 和 YouTube 凭证是 OAuth 类型，OAuth 客户端的创建方法见 [Google OAuth 单服务凭证](/zh/integrations/builtin/credentials/google/oauth-single-service.md#create-an-oauth-client)。

## Google Workspace Admin OAuth2 API <a href="#google-workspace-admin-oauth2-api" id="google-workspace-admin-oauth2-api"></a>

在 Duaer 里新建 Google Workspace Admin OAuth2 API 凭证，填写这些字段：

- Client ID（必填）
- Client Secret（必填，密钥）
- Custom Scopes：自定义授权范围。默认关闭。
- Enabled Scopes：要启用的授权范围。已预填，Custom Scopes 打开时显示。

Duaer 对这种类型固定使用 OAuth2 Authorization Code（授权码） 授权方式。

在服务商的应用设置里登记 Duaer 凭证窗口显示的 OAuth 重定向地址（https://<你的 Duaer 地址>/rest/oauth2-credential/callback），再在 Duaer 里点「连接我的账号」并同意授权。

Duaer 默认申请的授权范围：https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.user https://www.googleapis.com/auth/admin.directory.domain.readonly https://www.googleapis.com/auth/admin.directory.userschema.readonly https://www.googleapis.com/auth/admin.directory.device.chromeos https://www.googleapis.com/auth/admin.directory.orgunit.readonly。

所有 Duaer OAuth2 凭证共有的可选设置：Ignore SSL Issues (Insecure)、Token Expired Status Code、Encrypted Tokens (JWE)、JWKS URI。说明见 [OAuth2 API](/zh/integrations/builtin/credentials/httprequest.md#oauth2-api)。

使用它的 Duaer 节点：[Google Workspace Admin](/zh/integrations/builtin/app-nodes/duaer-nodes-base.gsuiteadmin.md)。

## YouTube OAuth2 API <a href="#youtube-oauth2-api" id="youtube-oauth2-api"></a>

在 Duaer 里新建 YouTube OAuth2 API 凭证，填写这些字段：

- Client ID（必填）
- Client Secret（必填，密钥）
- Custom Scopes：自定义授权范围。默认关闭。
- Enabled Scopes：要启用的授权范围。已预填，Custom Scopes 打开时显示。

Duaer 对这种类型固定使用 OAuth2 Authorization Code（授权码） 授权方式。

在服务商的应用设置里登记 Duaer 凭证窗口显示的 OAuth 重定向地址（https://<你的 Duaer 地址>/rest/oauth2-credential/callback），再在 Duaer 里点「连接我的账号」并同意授权。

Duaer 默认申请的授权范围：https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtubepartner https://www.googleapis.com/auth/youtube.force-ssl https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtubepartner-channel-audit。

所有 Duaer OAuth2 凭证共有的可选设置：Ignore SSL Issues (Insecure)、Token Expired Status Code、Encrypted Tokens (JWE)、JWKS URI。说明见 [OAuth2 API](/zh/integrations/builtin/credentials/httprequest.md#oauth2-api)。

使用它的 Duaer 节点：[YouTube](/zh/integrations/builtin/app-nodes/duaer-nodes-base.youtube.md)。

## Google Gemini(PaLM) Api <a href="#google-gemini-palm-api" id="google-gemini-palm-api"></a>

在 Duaer 里新建 Google Gemini(PaLM) Api 凭证，填写这些字段：

- Host（必填）：默认 https://generativelanguage.googleapis.com。
- API Key（必填，密钥）

保存时，Duaer 会用这些值测试一次连接。

使用它的 Duaer 节点：[Google Gemini](/zh/integrations/builtin/app-nodes/n8n-nodes-langchain.googlegemini.md)、[Embeddings Google Gemini](/zh/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.embeddingsgooglegemini.md)、[Google Gemini Chat Model](/zh/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatgooglegemini.md)。

## 在 Duaer 里保存连接

打开 Credentials，创建 Google。按字段填写密钥、OAuth 或服务器地址。保存后，工作流程节点引用这份凭证，而不是把密钥写进参数。

凭证内容经实例的加密密钥保护。换密钥或弄丢密钥后，已存凭证会解不开，见托管文档里的加密密钥说明。

## 谁能用这份凭证

能否看到或编辑，取决于项目和角色。不要把密钥贴进聊天或变量。外部密钥库见外部密钥文档。
## Questions

### Duaer 的 Google 凭证密钥会出现在节点参数里吗？

不会。在 Duaer 里，Google 的密钥保存在凭证中，节点只引用凭证。执行记录也不应出现明文密钥。

### 在 Duaer 里 Google 凭证保存失败常见原因是什么？

字段填错、OAuth 回调地址与实例 URL 不一致，或当前角色不能创建凭证。先核对 Google 服务商要求的字段，再确认你在该项目里有权新建凭证。

