> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 数据源授权

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

## 数据源授权界面入口

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

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

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

<img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-1.PNG?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=6cfb32c02e336fe04ece8bac3abe2170" alt="流水线授权界面" width="1280" height="435" data-path="images/knowledge-base/authorize-data-1.PNG" />

### 方式二：设置界面

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

<img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-2.PNG?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=77b73db7670358270b79d68c2504748a" alt="设置授权界面" width="1280" height="619" data-path="images/knowledge-base/authorize-data-2.PNG" />

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

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

## 授权方式和流程

### API Key 授权

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

#### 授权流程

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

   <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-3.PNG?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=703220410faaf6ae7d4a1cefc2c2406c" alt="添加API Key" width="1381" height="256" data-path="images/knowledge-base/authorize-data-3.PNG" />

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

   <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-4.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=85adbcc02ad555c7fcbaeed941293cc1" alt="API Key配置" width="1280" height="720" data-path="images/knowledge-base/authorize-data-4.png" />

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

<img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-6.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=33786eb3cadf2fc9c3b7f9d6bb8fdaec" alt="API Key 配置完成" width="1328" height="256" data-path="images/knowledge-base/authorize-data-6.png" />

### OAuth 授权

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

#### 授权流程

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

   <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-7.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=fb255648c553b8f94e1186e94b77f364" alt="添加OAuth" width="1280" height="305" data-path="images/knowledge-base/authorize-data-7.png" />

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

   <div style={{display: 'flex', flexWrap: 'wrap', gap: '30px'}}>
     <div style={{flex: 1, minWidth: '300px'}}>
       <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-8.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=8f9f70a50c5076c111d5942efcd46d5b" alt="OAuth权限确认" width="1242" height="1242" data-path="images/knowledge-base/authorize-data-8.png" />
     </div>

     <div style={{flex: 1, minWidth: '300px'}}>
       <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-9.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=b048f69c35096c4e4c74ca31dc372144" alt="允许访问" width="1280" height="1280" data-path="images/knowledge-base/authorize-data-9.png" />
     </div>
   </div>

#### OAuth 客户端设置

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

   <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-11.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=9b647024ca672f73e380888d75e6320e" alt="自定义OAuth设置" width="1280" height="364" data-path="images/knowledge-base/authorize-data-11.png" />

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

   <img src="https://mintcdn.com/dify-4171f9f9/vMKCXdVD-5Kdilzi/images/knowledge-base/authorize-data-12.png?fit=max&auto=format&n=vMKCXdVD-5Kdilzi&q=85&s=b0c38b55b5f8aa9e066b59230b622ba5" alt="自定义OAuth配置" width="1198" height="1240" data-path="images/knowledge-base/authorize-data-12.png" />
