2022最新如何rclone挂载google drive 谷歌网盘和one drive方法

一、前置准备:

1.首先你需要一个可以全局vpn的工具(挂载谷歌网盘才能返回token,onedrive不需要)。推荐萌咖大佬的anyconnect

在自己的windows电脑上下载windows版本rclone并解压到文件夹,最好修改文件夹名为rclone

https://rclone.org/downloads/

解压好window版本的rlcone,在rclone的文件夹里按住shift右键-在此处打开powershell窗口,根据想设置GD还是OD输入授权命令。

GD授权命令:

./rclone authorize "drive"

OD授权命令:

./rclone authorize "onedrive"

会自动跳转到浏览器授权,授权完成后,返回powershell,即可得到token。就是{}中的内容,全部复制(包括括号)。

2.GD需要手动获取客户端ID和密钥:

打开网址:

https://console.developers.google.com/

点击左上角三个点那里,选择新建项目,随便起个名字,我这里是transfer

在“已启用的API 和服务”下,点击+号启用API和服务,然后搜索drive,然后启用Google Drive API。

返回左侧的OAuth 同意屏幕,单击“配置同意屏幕”按钮(靠近右侧面板的右上角),然后选择“外部”并单击“创建”;在下一个屏幕上,输入“应用程序名称”(“rclone”是OK的);输入“用户支持电子邮件”(您自己的电子邮件是可以的);输入“开发人员联系电子邮件”(您自己的电子邮件正常);然后点击“保存”(所有其他数据都是可选的)。

再次单击左侧面板上的“凭据”以返回到“凭据”屏幕。返回左侧的 凭据 ,点击凭据,然后创建凭据,选择“OAuth 客户端 ID”。

选择“桌面应用程序”的应用程序类型,然后单击“创建”。将显示客户端 ID 和客户端密码。记下来。

转到“Oauth同意屏幕”,然后按“发布应用程序”

二、正式安装

1.在VPS上安装最新版rclone

curl https://rclone.org/install.sh | sudo bash

执行命令:

rclone config
[root@Rocky]# rclone config    #运行命令
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n                       #选择n
name> mydirve #随意的名称,回车后出现下列选项,选Google Drive对应的序号
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
 4 / Amazon Drive
   \ (amazon cloud drive)
 5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, RackCorp, SeaweedFS, and Tencent COS
   \ (s3)
 6 / Backblaze B2
   \ (b2)
 7 / Better checksums for other remotes
   \ (hasher)
 8 / Box
   \ (box)
 9 / Cache a remote
   \ (cache)
10 / Citrix Sharefile
   \ (sharefile)
11 / Compress a remote
   \ (compress)
12 / Dropbox
   \ (dropbox)
13 / Encrypt/Decrypt a remote
   \ (crypt)
14 / Enterprise File Fabric
   \ (filefabric)
15 / FTP Connection
   \ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
   \ (google cloud storage)
17 / Google Drive
   \ (drive)
18 / Google Photos
   \ (google photos)
19 / Hadoop distributed file system
   \ (hdfs)
20 / Hubic
   \ (hubic)
21 / In memory object storage system.
   \ (memory)
22 / Jottacloud
   \ (jottacloud)
23 / Koofr, Digi Storage and other Koofr-compatible storage providers
   \ (koofr)
24 / Local Disk
   \ (local)
25 / Mail.ru Cloud
   \ (mailru)
26 / Mega
   \ (mega)
27 / Microsoft Azure Blob Storage
   \ (azureblob)
28 / Microsoft OneDrive
   \ (onedrive)
29 / OpenDrive
   \ (opendrive)
30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ (swift)
31 / Pcloud
   \ (pcloud)
32 / Put.io
   \ (putio)
33 / QingCloud Object Storage
   \ (qingstor)
34 / SSH/SFTP Connection
   \ (sftp)
35 / Sia Decentralized Cloud
   \ (sia)
36 / Storj Decentralized Cloud Storage
   \ (storj)
37 / Sugarsync
   \ (sugarsync)
38 / Transparently chunk/split large files
   \ (chunker)
39 / Union merges the contents of several upstream fs
   \ (union)
40 / Uptobox
   \ (uptobox)
41 / Webdav
   \ (webdav)
42 / Yandex Disk
   \ (yandex)
43 / Zoho
   \ (zoho)
44 / http Connection
   \ (http)
45 / premiumize.me
   \ (premiumizeme)
46 / seafile
   \ (seafile)

到了这里,GD和OD开始不同了。

我这里17是GD,28是OD。

2.先设置GD:

选择17之后,

Option client_id.
Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a value. Press Enter to leave empty.
client_id>        #填入API中的 客户端ID
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret>     #填入API中的 客户端密钥
Enter a value. Press Enter to leave empty.
client_secret> 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
Option scope.
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 1 / Full access all files, excluding Application Data Folder.
   \ (drive)
 2 / Read-only access to file metadata and file contents.
   \ (drive.readonly)
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ (drive.file)
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ (drive.appfolder)
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ (drive.metadata.readonly)
scope> 1                  #选1吧
Option root_folder_id.
ID of the root folder.
Leave blank normally.
Fill in to access "Computers" folders (see docs), or for rclone to use
a non root folder as its starting point.
Enter a value. Press Enter to leave empty.
root_folder_id>             #回车
Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>      #回车
Edit advanced config?
y) Yes
n) No (default)
y/n>                      #回车
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine

y) Yes (default)
n) No
y/n> n                    #选n
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
    rclone authorize "drive" "eyJjbGllbnRfaWQiOiI0Mjg3DMtaGRtNGRubmcwZm5obDBuYzFmd"
Then paste the result.
Enter a value.
config_token>

到这了,v1.58.0没出现网址,那我们直接把用windows powershell授权过的token复制过来就是大括号{}的内容(包括大括号),然后点击回车

Configure this as a Shared Drive (Team Drive)?

y) Yes
n) No (default)
y/n>               #回车
--------------------
[mydirve]
type = drive
client_id = xxxxxx.apps.googleusercontent.com
client_secret = GOCSPX-dx0Xuxxxxxxx
scope = drive
token = {"access_token":"xxxxxx","expiry":"2022-04-01T23:23:11.4589091+08:00"}
team_drive =
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>               #回车
Current remotes:

Name                 Type
====                 ====
gd                   drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q     #选q退出

3.OD的操作也一样:

选择28之后,

client_id> #直接回车
client_secret> #直接回车
scope> 1 #选1
root_folder_id> #回车
service_account_file> #回车
Edit advanced config?  #选n或者直接回车
Use auto config?
* Say Y if not sure 
* Say N if you are working on a remote or headless machine y) 
Yes (default) n) No y/n> n #选n

 

这里也是直接把windows 获取的token直接粘贴进来

config_token>
--------------------中间省略
 #最后选择q退出

三、挂载

#新建本地文件夹,路径自己定
mkdir /root/OneDrive
rclone mount drive:/ /root/GoogleDrive --copy-links --allow-other --allow-non-empty --umask 000 --daemon

然后输入 df -h 命令查看挂载情况。