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

# 数据源授权

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

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

## 数据源授权界面入口

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

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

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

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-01.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=9e62e3dffd3d9ff70716a140da599d9f" alt="流水线授权界面" width="1280" height="435" data-path="images/use-dify/knowledge/authorize-data-01.png" />
</Frame>

### 方式二：设置界面

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

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-02.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=95cfdfa52023c9534880484ce9f13014" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-03.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=2d59afb83f97b0365c66972c46d7bc2e" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-04.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=05a0bc7ba4beedfe8e9b6047863c20b6" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-06.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=b85e897d060c990726c80b462038d453" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-07.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=1bc674179d8cd5d0eebf339857dcf815" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-08.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=ded3123c4a04b68a8d527272717b0d84" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-09.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=e46801d92dcd07937b93c586b33e9de7" alt="允许访问" width="1280" height="1280" data-path="images/use-dify/knowledge/authorize-data-09.png" />
       </Frame>
     </div>
   </div>

#### OAuth 客户端设置

使用自定义 OAuth 客户端授权数据源：先在第三方平台注册一个 OAuth 应用，再将其 **Client ID** 和 **Client Secret** 填入 Dify。当你有特定的安全或合规要求时，这种方式尤为适用。

<Frame>
  <img src="https://mintcdn.com/dify-6c0370d8-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-10.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=cc5dbb49d15da2a8348f86d6edc3c1bb" alt="OAuth 客户端设置" width="1034" height="580" data-path="images/use-dify/knowledge/authorize-data-10.png" />
</Frame>

**授权流程**

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

   <Frame>
     <img src="https://mintcdn.com/dify-6c0370d8-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-11.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=db5667c0c6298b51a4d41f8f68fd0409" 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-codex-ee313-ce-unified-tracing/iTyKcq3pvR1mciuC/images/use-dify/knowledge/authorize-data-12.png?fit=max&auto=format&n=iTyKcq3pvR1mciuC&q=85&s=6fda1304e7322da8468387d99f8c20bf" alt="自定义 OAuth 配置" width="1198" height="1240" data-path="images/use-dify/knowledge/authorize-data-12.png" />
   </Frame>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.