Google Drive
Official website: https://drive.google.com/
- Supports Team Drive (Enter the Team Drive directory ID for the Root Folder ID)
- 支持团队盘(根目录ID填写团队盘的目录ID)
1. Prerequisites
1. 必要条件
The machine on which the OpenList service is deployed must be able to connect to Google Drive.
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.
搭建 OpenList 服务的机器必须能够连接到 Google 网盘。
必须启用 Google 云盘 API 服务,具体启用方式请参考 启用 Google Drive API。
2. Preparation
2. 准备接入
2.1. Enable Google Drive API
2.1. 启用 Google Drive API 的 API
On the Guide Page, locate the
Enable the APIbutton and click to proceed to the quick activation interface. Follow the instructions and confirm the settings to complete the activation process.You can also visit the Google Drive API Management Interface. Find the
Enablebutton at the top and click it; wait for the activation to complete.Quotas and System Limits Management(optional): Switch to theQuotas and System Limitstab and set appropriate quotas and limits based on your usage and requirements.
在指南页面中找到
启用API按钮,点击进入快捷开启界面,点击下一步以及确认后,即可完成开启。也可以访问谷歌云盘API功能管理界面,在上方找到
启用按钮,点击后等待启用完成。配额和系统限制管理(可选):切换到配额和系统限制选项卡,根据你的使用情况和需求,设置合适的配额和限制。
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/公益服务器/自建服务器,则不用创建)
On the Credentials Page, click the
Create Credentialsdropdown menu and select and clickOAuth client ID.If prompted with
To create an OAuth client ID, you must first configure the consent screen, click theConfigure consent screenbutton, and complete the creation of theBrand Informationon the subsequent page, selectingExternalfor theAudience. After completion, return to the Credentials page to continue creating the OAuth client ID.
In the pop-up window, select
Web Applicationand enter the name of your application type.For the
Authorized redirect URIs, enterhttps://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.Click the
Createbutton to complete the creation of the OAuth client. Note: Make sure to copy and save theClient IDandClient Secret; you will need them later on.
Add yourself as a test user: On the left side, find the
Audiencemenu and click to enter it. Then, locateTest Usersand click the+ Add usersbutton. Enter your Google account email address and clickSave.
After completing the testing, you can publish your application: On the left side, find the
Audiencemenu and click to enter it. Then, locatePublication Statusand click thePublish appbutton. Confirm the publication to complete the application release process.
在凭据界面中,点击
创建凭据下拉菜单,选择和点击OAuth 客户端 ID如果提示
如需创建 OAuth 客户端 ID,您必须先配置权限请求页面,请点击配置同意屏幕按钮,在后续页面中完成品牌信息的创建,其中受众群体请选择外部用户,完成后返回凭据页面继续创建 OAuth 客户端 ID。
在弹出的窗口中,选择
Web 应用,填写应用名称在
授权的重定向 URI中,填写https://api.oplist.org/googleui/callback,如果是自建或者公益服务,请填写对应的域名,如https://your-domain.com/googleui/callback。点击
创建按钮,完成 OAuth 客户端的创建。注:请复制和保存客户端 ID和客户端密钥,后续需要使用。
将自己添加到测试用户中,在左侧找到
目标对象菜单,点击进入后,找到测试用户下方的+ Add User按钮,点击后输入你的 Google 账号邮箱地址,点击添加即可。
测试完毕后可以发布应用,在左侧找到
目标对象菜单,点击进入后,找到发布状态下方的发布应用按钮,点击后确认发布即可完成应用发布。
2.3. Get Access Token and Refresh Token
2.3. 获取访问密钥和刷新密钥
Open the OpenList Google Authorization Page. ⚠️ If you are using a public or self-hosted server, please proceed with that server.
In the dropdown menu on the page, select
GoogleDrive Login.

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


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.


Click the
Get Authorizationbutton. The system will redirect you to the Google Authorization page. Log in to your Google account and authorize OpenList to access your Google Drive.
If a message appears stating
This app has not been verified by Google, clickAdvancedand then clickGo 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.)
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.

After authorization is successful, the system will provide you with a
Refresh Tokenand anAccess Token. Please copy and save these tokens, as they will be used in subsequent configurations.

打开OpenList Google 授权页面 ⚠️如果使用公益服务器/自建服务器,请访问公益服务器/自建服务器
在页面中下拉框中选择
GoogleDrive Login

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

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


点击
获取授权按钮,系统会跳转到 Google 授权页面,登录你的 Google 账号,并授权 OpenList 访问你的 Google Drive。
如果出现
此应用未经 Google 验证的提示,请点击高级,然后点击转至oplist.org(不安全)继续。(如果是公益服务器/自建服务器,则此处域名以实际公益服务的域名为准,请仔细甄别)。
请注意授权页面上(下图红色框内)的权限信息,确保只是访问你的 谷歌云端硬盘文件,如果在公益服务中发现该权限不仅仅是访问谷歌云端硬盘,请在OpenListTeam/OpenList-Docs/issues提起issues。

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

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:

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

3.2. Start Adding
3.2. 开始添加
Open the management interface of OpenList and click on
Storagein the left menu.On the Storage List page, click the
Add Storagebutton in the top right corner.Select
Google Driveas the drive.

Enter the mount path, for example:
google-drive.In the
Root Folder IDfield, enter the root folder ID obtained earlier; if you are using the root directory, enterroot.In the
Refresh Tokenfield, enter the refresh token obtained earlier (if not available, refer to Preparing for Integration.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 APIoption to indicate that you want to use the online API provided by OpenList.7.2. Enter
https://api.oplist.org/googleui/renewapias the API URL; if it’s a public welfare server/self-built server, enter the corresponding server address.

If you are using your own OAuth client ID and key, follow steps 8.1 and 8.2:
8.1. Uncheck the
Use online APIoption to indicate that you are using your own OAuth client ID and key.8.2. Enter your OAuth client ID in the
Client idfield and your OAuth Client secrets in theClient secretfield.

Click the
Addbutton to complete the addition of Google Drive.
打开 OpenList 的管理界面,点击左侧菜单中的
存储。在存储列表页面,点击右上角的
添加存储按钮。选择驱动为
谷歌云盘(Google Drive)。

输入挂载路径,如:
google-drive。在
根文件夹 ID中填写上面获取的根文件夹 ID,如果使用根目录,请填写root。刷新令牌中填写上面获取的刷新令牌(如未获取,请参考准备接入)。
如果你使用的是
OpenList (或者公益服务器/自建服务器)提供的 OAuth 客户端 ID 和密钥,请按照7.1和7.2进行配置7.1. 在
Use online api中勾选,表示使用 OpenList 提供的在线 API。7.2. Api url address填写为
https://api.oplist.org/googleui/renewapi,如果是公益服务器/自建服务器,请填写对应的服务器地址。

如果你使用的是自己创建的 OAuth 客户端 ID 和密钥,请按照
8.1和8.2进行配置8.1. 在
Use online api中不勾选,表示使用自建的 OAuth 客户端 ID 和密钥。8.2. 在
客户端ID中填写你的Oauth 客户端 ID,在客户端密钥中填写你的Oauth 客户端密钥

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