> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-release-1-14.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 数据源授权

<Note> ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处，请参考 [英文原版](/en/use-dify/knowledge/knowledge-pipeline/authorize-data-source)。</Note>

Dify 支持多种外部数据源的连接，为了确保数据安全和访问控制，不同的数据源需要进行相应的授权配置。根据数据源的特性，Dify 提供两种主要的授权方式：**API Key** 和 **OAuth**，以确保你能够安全地访问和导入所需的数据。

## 数据源授权界面入口

在 Dify 中，你可以通过以下两种方式进入数据源授权配置界面：

### 方式一：通过知识流水线编排界面

进入知识流水线编排界面，添加需要的数据源。选中数据源节点，在右侧面板中，点击**绑定**。

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-01.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=1072120631fbbb6acd76f9bdd18e0876" alt="流水线授权界面" width="1280" height="435" data-path="images/use-dify/knowledge/authorize-data-01.png" />
</Frame>

### 方式二：设置界面

点击右上角头像，选择**设置**，点击**数据来源**。进入数据来源页面后，选择需要授权的数据源，点击**配置**。

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-02.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=9a8096cec936ce77bf8823c9ede4e209" alt="设置授权界面" width="1280" height="619" data-path="images/use-dify/knowledge/authorize-data-02.png" />
</Frame>

## 支持数据源及授权方式

| 数据源          | API Key | OAuth |
| ------------ | ------- | ----- |
| Notion       | ✅       | ✅     |
| Jina Reader  | ✅       |       |
| Firecrawl    | ✅       |       |
| Google Drive |         | ✅     |
| Dropbox      | ✅       | ✅     |
| OneDrive     |         | ✅     |

## 授权方式和流程

### API Key 授权

API Key 授权是一种基于密钥的身份验证方式，适用于企业级服务和开发者工具。用户需要在对应的服务提供商处生成 API Key，然后在 Dify 中进行配置。

#### 授权流程

1. 在数据源配置界面，选择对应的数据源，点击右侧的**配置**，选择**添加 API Key**。

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-03.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=b26d91c7d44e114c07e2d6ac414b75f4" alt="添加API Key" width="1381" height="256" data-path="images/use-dify/knowledge/authorize-data-03.png" />
   </Frame>

2. 在弹出的配置面板中，填写对应信息。完成后，点击**保存**完成授权。

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-04.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=0621511c0910fec0f4ba0abf6f957c6c" alt="API Key配置" width="1280" height="720" data-path="images/use-dify/knowledge/authorize-data-04.png" />
   </Frame>

API 密钥将被安全加密储存，配置成功后会显示 **Connected** 状态，你可以在知识流水线中使用该数据源。

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-06.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=102b11624eb1a11cbb7353ee0e43bdc0" alt="API Key 配置完成" width="1328" height="256" data-path="images/use-dify/knowledge/authorize-data-06.png" />
</Frame>

### OAuth 授权

OAuth 是一种开放标准的授权协议，允许用户在不暴露密码的情况下，授权第三方应用访问其在特定服务提供商上的资源。Dify 提供两种 OAuth 授权配置方式：默认配置和自定义配置。

#### 授权流程

1. 在数据源配置界面，选择对应的数据源，点击右侧的**配置**，选择**添加 OAuth**。

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-07.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=3654e09240d8a35515c558b771d0f69a" alt="添加OAuth" width="1280" height="305" data-path="images/use-dify/knowledge/authorize-data-07.png" />
   </Frame>

2. 在授权页面中查看并确认权限范围后，点击**允许访问**。

   <div style={{display: 'flex', flexWrap: 'wrap', gap: '30px'}}>
     <div style={{flex: 1, minWidth: '300px'}}>
       <Frame>
         <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-08.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=fc445e56abef4a4ff1aa0813dd184829" alt="OAuth权限确认" width="1242" height="1242" data-path="images/use-dify/knowledge/authorize-data-08.png" />
       </Frame>
     </div>

     <div style={{flex: 1, minWidth: '300px'}}>
       <Frame>
         <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-09.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=7a1a92f09f9f684ded56860f1194134e" alt="允许访问" width="1280" height="1280" data-path="images/use-dify/knowledge/authorize-data-09.png" />
       </Frame>
     </div>
   </div>

#### OAuth 客户端设置

Dify 提供默认和自定义两种 OAuth 客户端配置方式。

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-10.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=f206fd568bba00722ab5c9436bca50d2" alt="OAuth客户端设置" width="1034" height="580" data-path="images/use-dify/knowledge/authorize-data-10.png" />
</Frame>

* **默认客户端**\
  仅 SaaS 版本支持默认客户端，你可以使用 Dify 官方预配置并维护的 OAuth 客户端参数，在 SaaS 版本一键添加 OAuth 凭据，无需进行额外的配置。

* **自定义客户端**\
  Dify 所有版本均支持自定义客户端。对于 SaaS 版本中尚未提供的默认配置数据源，你需要前往第三方平台自行注册并获取 OAuth 客户端参数。

**授权流程**

1. 在数据源配置界面，选择对应的数据源，点击右侧的**配置**，选择**添加 OAuth** 右侧的**设置图标**，进入 OAuth 客户端设置。

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-11.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=75c5beacf6c22d55273b34d72e5f9174" alt="自定义OAuth设置" width="1280" height="364" data-path="images/use-dify/knowledge/authorize-data-11.png" />
   </Frame>

2. 点击**自定义**，输入 **Client ID** 和 **Client Secret**。点击**保存并授权**完成 OAuth 授权流程。

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-release-1-14/lW9oe4J6JoN3ZHrN/images/use-dify/knowledge/authorize-data-12.png?fit=max&auto=format&n=lW9oe4J6JoN3ZHrN&q=85&s=c3ed6c3f1e2a5989c7b8d4a6c5e7dbbc" alt="自定义OAuth配置" width="1198" height="1240" data-path="images/use-dify/knowledge/authorize-data-12.png" />
   </Frame>
