Google Drive

Official website: https://drive.google.com/

  • Supports Team Drive (Enter the Team Drive directory ID for the Root Folder ID)

官网:https://drive.google.com/

  • 支持团队盘(根目录ID填写团队盘的目录ID)

1. Prerequisites

1. 必要条件

  1. The machine on which the OpenList service is deployed must be able to connect to Google Drive.

  2. The Google Drive API service must be enabled. For details on how to enable it, please refer to Enabling the Google Drive API.

    For detailed steps, see Google Workspace > Google Drive > Quick Start Guide.

  1. 搭建 OpenList 服务的机器必须能够连接到 Google 网盘。

  2. 必须启用 Google 云盘 API 服务,具体启用方式请参考 启用 Google Drive API

    详细步骤可参考 Google Workspace > Google Drive > 快速入门指南

2. Preparation

2. 准备接入

2.1. Enable Google Drive API

2.1. 启用 Google Drive API 的 API

  1. On the Guide Page, locate the Enable the API button and click to proceed to the quick activation interface. Follow the instructions and confirm the settings to complete the activation process.

  2. You can also visit the Google Drive API Management Interface. Find the Enable button at the top and click it; wait for the activation to complete.

  3. Quotas and System Limits Management(optional): Switch to the Quotas and System Limits tab and set appropriate quotas and limits based on your usage and requirements.

  1. 指南页面中找到启用API按钮,点击进入快捷开启界面,点击下一步以及确认后,即可完成开启。

  2. 也可以访问谷歌云盘API功能管理界面,在上方找到启用按钮,点击后等待启用完成。

  3. 配额和系统限制管理(可选):切换到配额和系统限制选项卡,根据你的使用情况和需求,设置合适的配额和限制。

2.2. Creating an OAuth Client (Optional; not required if using OpenList, a public welfare server, or a self-built server)

2.2. 创建 OAuth 客户端(可选,如果使用OpenList/公益服务器/自建服务器,则不用创建)

  1. On the Credentials Page, click the Create Credentials dropdown menu and select and click OAuth client ID.

    If prompted with To create an OAuth client ID, you must first configure the consent screen, click the Configure consent screen button, and complete the creation of the Brand Information on the subsequent page, selecting External for the Audience. After completion, return to the Credentials page to continue creating the OAuth client ID. google-oauth-00

  2. In the pop-up window, select Web Application and enter the name of your application type.

  3. For the Authorized redirect URIs, enter https://api.oplist.org/googleui/callback. If you are using a self-built service or a non-profit organization, please enter the corresponding domain name, for example, https://your-domain.com/googleui/callback.

  4. Click the Create button to complete the creation of the OAuth client. Note: Make sure to copy and save the Client ID and Client Secret; you will need them later on.

    google-oauth-01
  5. Add yourself as a test user: On the left side, find the Audience menu and click to enter it. Then, locate Test Users and click the + Add users button. Enter your Google account email address and click Save.

    google-oauth-02
  6. After completing the testing, you can publish your application: On the left side, find the Audience menu and click to enter it. Then, locate Publication Status and click the Publish app button. Confirm the publication to complete the application release process.

    google-oauth-03
  1. 凭据界面中,点击创建凭据下拉菜单,选择和点击OAuth 客户端 ID

    如果提示如需创建 OAuth 客户端 ID,您必须先配置权限请求页面,请点击配置同意屏幕按钮,在后续页面中完成品牌信息的创建,其中受众群体请选择外部用户,完成后返回凭据页面继续创建 OAuth 客户端 ID。

    google-oauth-00
  2. 在弹出的窗口中,选择Web 应用,填写应用名称

  3. 授权的重定向 URI中,填写 https://api.oplist.org/googleui/callback,如果是自建或者公益服务,请填写对应的域名,如 https://your-domain.com/googleui/callback

  4. 点击创建按钮,完成 OAuth 客户端的创建。注:请复制和保存客户端 ID客户端密钥,后续需要使用。

    google-oauth-00
  5. 将自己添加到测试用户中,在左侧找到目标对象菜单,点击进入后,找到测试用户下方的+ Add User按钮,点击后输入你的 Google 账号邮箱地址,点击添加即可。

    google-oauth-02
  6. 测试完毕后可以发布应用,在左侧找到目标对象菜单,点击进入后,找到发布状态下方的发布应用按钮,点击后确认发布即可完成应用发布。

    google-oauth-03

2.3. Get Access Token and Refresh Token

2.3. 获取访问密钥刷新密钥

  1. Open the OpenList Google Authorization Page. ⚠️ If you are using a public or self-hosted server, please proceed with that server.

  2. In the dropdown menu on the page, select GoogleDrive Login.

    google-00-lgoogle-00-d

  3. If you created an OAuth Client ID in the previous steps, please enter the Client ID and Client Secrets in the input fields below.

    google-01-01-lgoogle-01-01-d

    Otherwise, check the box ☑️ to use the API provided by OpenList. ⚠️ If you are using a public or self-hosted server, the built-in Client ID and Client Secrets of that server will be used.

    google-01-02-lgoogle-01-02-d

  4. Click the Get Authorization button. The system will redirect you to the Google Authorization page. Log in to your Google account and authorize OpenList to access your Google Drive.

    google-02
  5. If a message appears stating This app has not been verified by Google, click Advanced and then click Go to oplist.org (insecure) to continue. (If you are using a public or self-hosted server, the domain name here should match the actual domain name of the service; please verify this carefully.)

    google-03
  6. Pay attention to the permission information on the authorization page (within the red box in the image below). Make sure that the permission granted is only for accessing your Google Drive files. If you find that the permission includes access to something other than just your Google Drive files in the public service, please report an issue at OpenListTeam/OpenList-Docs/issues.

    google-04
  7. After authorization is successful, the system will provide you with a Refresh Token and an Access Token. Please copy and save these tokens, as they will be used in subsequent configurations.

    google-05-lgoogle-05-d

  1. 打开OpenList Google 授权页面 ⚠️如果使用公益服务器/自建服务器,请访问公益服务器/自建服务器

  2. 在页面中下拉框中选择GoogleDrive Login

    google-00-lgoogle-00-d

  3. 如果在上面的步骤中创建了 OAuth 客户端 ID,请在下方输入框中填写刚才创建的客户端 ID客户端密钥

    google-01-01-lgoogle-01-01-d

    否则勾选☑️使用 OpenList 提供的API。⚠️如果使用的公益服务器/自建服务器,此时使用的是公益服务器/自建服务器内置的客户端ID和应用机密

    google-01-02-lgoogle-01-02-d

  4. 点击获取授权按钮,系统会跳转到 Google 授权页面,登录你的 Google 账号,并授权 OpenList 访问你的 Google Drive。

    google-02
  5. 如果出现此应用未经 Google 验证的提示,请点击高级,然后点击转至oplist.org(不安全)继续。(如果是公益服务器/自建服务器,则此处域名以实际公益服务的域名为准,请仔细甄别)。

    google-03
  6. 请注意授权页面上(下图红色框内)的权限信息,确保只是访问你的 谷歌云端硬盘文件,如果在公益服务中发现该权限不仅仅是访问谷歌云端硬盘,请在OpenListTeam/OpenList-Docs/issues提起issues。

    google-04
  7. 授权成功后,系统会返回一个刷新密钥访问密钥,请复制并保存该令牌,后续的配置中会使用。

    google-05-lgoogle-05-d

3. Add Google Drive in OpenList

3. 在 OpenList 中添加谷歌云盘

3.1. Configuration

3.1. 配置说明

3.1.1. Root Folder ID

3.1.1. 根文件夹 ID

Similar to Aliyun Drive, it is the last string of the official website URL, such as:

google

与阿里云盘类似,官网 URL 的最后一个字符串,如:

google

3.2. Start Adding

3.2. 开始添加

  1. Open the management interface of OpenList and click on Storage in the left menu.

  2. On the Storage List page, click the Add Storage button in the top right corner.

  3. Select Google Drive as the drive.

    google-06-lgoogle-06-d

  4. Enter the mount path, for example: google-drive.

  5. In the Root Folder ID field, enter the root folder ID obtained earlier; if you are using the root directory, enter root.

  6. In the Refresh Token field, enter the refresh token obtained earlier (if not available, refer to Preparing for Integration.

  7. If you are using the OAuth client ID and key provided by OpenList (or a public welfare server/self-built server), follow steps 7.1 and 7.2:

    7.1. Check the Use online API option to indicate that you want to use the online API provided by OpenList.

    7.2. Enter https://api.oplist.org/googleui/renewapi as the API URL; if it’s a public welfare server/self-built server, enter the corresponding server address.

    google-07-dgoogle-07-l

  8. If you are using your own OAuth client ID and key, follow steps 8.1 and 8.2:

    8.1. Uncheck the Use online API option to indicate that you are using your own OAuth client ID and key.

    8.2. Enter your OAuth client ID in the Client id field and your OAuth Client secrets in the Client secret field.

    google-08-lgoogle-08-d

  9. Click the Add button to complete the addition of Google Drive.

  1. 打开 OpenList 的管理界面,点击左侧菜单中的存储

  2. 在存储列表页面,点击右上角的添加存储按钮。

  3. 选择驱动为谷歌云盘(Google Drive)

    google-06-lgoogle-06-d

  4. 输入挂载路径,如:google-drive

  5. 根文件夹 ID中填写上面获取的根文件夹 ID,如果使用根目录,请填写root

  6. 刷新令牌中填写上面获取的刷新令牌(如未获取,请参考准备接入)。

  7. 如果你使用的是 OpenList (或者公益服务器/自建服务器)提供的 OAuth 客户端 ID 和密钥,请按照7.17.2进行配置

    7.1. 在Use online api中勾选,表示使用 OpenList 提供的在线 API。

    7.2. Api url address填写为 https://api.oplist.org/googleui/renewapi,如果是公益服务器/自建服务器,请填写对应的服务器地址。

    google-07-dgoogle-07-l

  8. 如果你使用的是自己创建的 OAuth 客户端 ID 和密钥,请按照8.18.2进行配置

    8.1. 在Use online api中不勾选,表示使用自建的 OAuth 客户端 ID 和密钥。

    8.2. 在客户端ID中填写你的Oauth 客户端 ID,在客户端密钥中填写你的Oauth 客户端密钥

    google-08-lgoogle-08-d

  9. 点击添加按钮,完成谷歌云盘的添加。

4. About Use online api option

4. 关于Use online api选项的说明

4.1. AccessToken refresh method with own keys

4.1. 自身有密钥的情况下,AccessToken刷新的方式

4.2. AccessToken refresh method without own keys

4.2.自身没有密钥的情况下,AccessToken刷新的方式

5. The default download method used

5. 默认使用的哪种下载方式?

Contributors