跳到主要内容

使用你自己的 Google Drive 客户端 ID

当 Google Drive 远程没有 client_id 时,rclone 会使用 rclone 的共享客户端 ID 登录。这个客户端 ID 的请求配额由众多 rclone 用户共同使用,因此使用它的远程可能会变慢,或因 403 错误而失败。rclone 文档还指出,共享客户端 ID 正在停用,将在 2026 年内停止工作。

当 client_id 为空时,RcloneView 会在 Add Google Drive 和 Edit Remote 对话框中显示以下提示:

Add Google Drive dialog showing the shared client ID notice and the How to create your own client ID link

本指南介绍如何在 Google Cloud 控制台中创建你自己的客户端 ID 和客户端密钥,将其填入 RcloneView,然后重新登录。第 1~5 步在 Google Cloud 控制台中完成,第 6~7 步在 RcloneView 中完成。

更喜欢看视频?这段 3 分钟的视频(英文字幕)演示了下面的每一个步骤。

以下步骤依据 rclone 的指南 Making your own client_id(即 How to create your own client ID 链接打开的页面),并与 2026 年 12 月的 Google Cloud 控制台界面一致。Google 会不时调整控制台界面;如果下面的名称与你看到的不一致,请查看 rclone 的指南。


第 1 步:创建项目并启用 Google Drive API​

  1. 登录 Google Cloud 控制台。任何 Google 账号都可以,不必与要连接的 Google Drive 账号相同。

  2. 打开页面顶部的项目选择器,新建一个项目(也可以选择现有项目)。输入 Project name(例如 rcloneview-client-id),然后点击 Create。如果你使用 Google Workspace 账号登录,还会显示填有你所在组织域名的 Organization 字段(下方截图使用的是 Workspace 账号),保持原样即可。使用个人 Google 账号(Gmail)时没有 Organization 字段,Location 显示为 No organization,同样保持原样即可。

    Google Cloud New Project page with the project name rcloneview-client-id and the Create button
  3. 确认页面顶部已选中新项目。在搜索栏中搜索 Google Drive API,打开它并点击 Enable。

    Google Drive API product details page with the Enable button

第 2 步:配置 OAuth 同意屏幕​

  1. 进入 APIs & Services › Credentials(点击左侧面板中的 Credentials,不要点 Create credentials,那会打开向导)。页面上会显示 "Remember to configure the OAuth consent screen" 横幅。点击 Configure consent screen,然后点击 Get started。

    Credentials page with the banner asking to configure the OAuth consent screen and the Configure consent screen button
  2. Project configuration 向导随即打开。在 1 App Information 中输入 App name(例如 rclone),选择 User support email(填你自己的邮箱即可),然后点击 Next。

    Project configuration wizard, App Information step with the App name rclone and a user support email
  3. 在 2 Audience 中选择 External,然后点击 Next。如果你使用 Google Workspace 账号,且只有组织内的用户会使用此客户端 ID,也可以选择 Internal;这样就不需要添加测试用户或发布应用(第 4 步)。

    Project configuration wizard, Audience step with Internal and External options and External selected
  4. 在 3 Contact Information 中输入 Google 用于发送项目相关通知的邮箱地址,然后点击 Next。

  5. 在 4 Finish 中勾选 I agree to the Google API Services User Data Policy,点击 Continue,再点击 Create。


第 3 步:添加 Google Drive 范围(scope)​

  1. 点击左侧面板中的 Data Access,然后点击 Add or remove scopes。Update selected scopes 面板随即打开。

  2. 向下滚动到 Manually add scopes,粘贴以下三个范围(每行一个,或用逗号分隔),然后点击 Add to table:

    • https://www.googleapis.com/auth/docs
    • https://www.googleapis.com/auth/drive
    • https://www.googleapis.com/auth/drive.metadata.readonly
    Update selected scopes panel with the three Google Drive scopes pasted into Manually add scopes
  3. 这三个范围会出现在表格顶部,并已勾选。点击面板底部的 Update。

    Update selected scopes panel with the docs, drive and drive.metadata.readonly scopes checked and the Update button
  4. 回到 Data Access 页面后,这些范围会列在 Your sensitive scopes 和 Your restricted scopes 下。点击页面底部的 Save。只有点击 Save 后,范围才会被保存。

    Data Access page listing the auth/docs scope under sensitive scopes and the auth/drive scopes under restricted scopes, with the Save button

第 4 步:将自己添加为测试用户​

如果你在第 2 步中选择了 Internal,请跳过此步。

  1. 点击左侧面板中的 Audience。在 Test users 下点击 + Add users。

  2. 输入拥有要连接的 Google Drive 的 Google 账号邮箱地址,然后点击 Save。

    Audience page with Publishing status Testing, a greyed-out Publish app button, and the Add users panel with one test user and the Save button

此时 Publishing status 为 Testing。在完成 Branding 页面之前,Publish app 按钮会一直是灰色的("To publish your app, you must complete your configuration on the Branding page")。Branding 需要应用主页、隐私政策链接和已授权网域(authorized domain)。详情请参阅 rclone 的指南。不发布应用,保持 Testing 状态也可以使用该客户端 ID。

测试与发布

你可以让应用保持 Testing 状态,但这样 Google 的登录授权大约一周后就会过期,需要重新登录。发布应用可以避免这个问题。个人使用(少于 100 个用户)通常不需要 Google 的应用验证(verification);登录时只会显示 "unverified app" 警告,接受即可。


第 5 步:创建 OAuth 客户端 ID​

  1. 点击左侧面板中的 Clients,新建一个客户端。在 Create OAuth client ID 页面中,Application type 选择 Desktop app。Name 保持默认(例如 Desktop client 1)即可。点击 Create。

    Create OAuth client ID page with Application type Desktop app, the name Desktop client 1 and the Create button
  2. OAuth client created 对话框会显示你的 Client ID 和 Client secret。使用复制按钮复制两者并妥善保存,或点击 Download JSON。然后点击 OK。

    OAuth client created dialog with the Client ID, the masked Client secret, the warning that the secret cannot be viewed again, and the Download JSON and OK buttons
关闭对话框前先复制客户端密钥

关闭 OAuth client created 对话框后,就无法再查看或下载客户端密钥。客户端 ID 之后随时可以在 Clients 中找到,但如果丢失了密钥,就必须新建一个客户端。请在点击 OK 之前复制客户端密钥或点击 Download JSON,并妥善保密。


第 6 步:在 RcloneView 中填入客户端 ID​

现有 Google Drive 远程​

  1. 打开该远程的 Edit Remote 对话框:在 Remote 选项卡中点击 Remote Manager,然后点击 Google Drive 远程卡片上的 Edit。也可以点击显示该远程的 Explorer 窗格右上角的 齿轮图标。参见 编辑远程设置。对话框中会显示共享客户端 ID 的提示。

    RcloneView Remote Manager with the Edit Google Drive dialog showing the shared client ID notice and the Show advanced options link
  2. 点击 Show advanced options。会出现 client_id 和 client_secret 字段。

    Edit Google Drive dialog with advanced options shown, including the empty client_id and client_secret fields
  3. 将客户端 ID 粘贴到 client_id,将客户端密钥粘贴到 client_secret。client_id 一有值,共享客户端 ID 的提示就会消失。

    Edit Google Drive dialog with client_id and client_secret filled in and the shared client ID notice gone
  4. 点击 Save,然后继续第 7 步。

新建 Google Drive 远程​

  1. 在 Remote 菜单中点击 + New Remote,然后选择 Google Drive。

    New Remote dialog with the list of providers including Google Drive
  2. 输入 Remote name。

  3. 点击 Show advanced options。client_id 和 client_secret 字段位于高级选项中。

  4. 将客户端 ID 粘贴到 client_id,将客户端密钥粘贴到 client_secret。

  5. 点击 Add Remote,然后继续第 7 步。


第 7 步:登录 Google​

使用共享客户端 ID 完成的 Google 登录不会沿用到你自己的客户端 ID,因此远程需要用新 ID 重新登录。

  1. 点击 Save(或 Add Remote)后,浏览器会像首次添加远程时一样打开 Google 登录页面。
  2. 使用拥有该 Google Drive 的账号登录(如果选择了 External,该账号必须是你在第 4 步中添加的测试用户),并允许访问。
  3. 应用处于 Testing 状态时,Google 可能会显示 "unverified app" 警告。它指的是你在第 2 步中创建的应用。点击 Advanced,然后点击 Go to rclone (unsafe)(显示的是你在第 2 步中输入的应用名称)。
  4. 浏览器会显示 rclone 的成功页面。关闭浏览器标签页,回到 RcloneView 即可。

如果保存后远程仍然失败,请使用相同的客户端 ID 和客户端密钥新建一个 Google Drive 远程(参见第 6 步的"新建 Google Drive 远程"),然后在 Remote Manager 中删除旧远程。

查看结果​

再次打开 Edit Remote 对话框。由于 client_id 现在已有值,共享客户端 ID 的提示不再显示。

Edit Google Drive dialog reopened after saving, without the shared client ID notice

现在,你的远程使用自己的请求配额,而不是众多 rclone 用户共享的配额,因此浏览文件夹通常会更快,也更不容易因 403 错误而失败。

Google Photos

Google Photos 远程同样需要自己的客户端 ID,但步骤不同(需要 Photos Library API 及其范围)。请参阅 rclone 的指南 Google Photos: Making your own client_id。

外部 rclone

本指南以 RcloneView 内置的 rclone 为前提,它可以在你的电脑上打开浏览器进行登录。如果 rclone 运行在没有浏览器的服务器上,请参阅 在 AWS EC2 上的外部 Rclone 中添加 Google Drive。


相关指南​