[教程]使用E5 OneDrive私有API,通过rclone挂载到vps

写在前面

撸的E5,一年多了,好像还蛮稳,一直没用,来给他挂载下玩玩吧,教程整合自多个网络搜索结果。

教程

获取E5 客户端ID,密钥,100年有效期方法

获取 token(在vps上进行设置的时候需要用到)

  • 在本地电脑上下载 rclone
  • 以 Windows 为例子,解压并进入rclone.exe所在文件夹,在资源管理器地址栏输入cmd,回车就会在当前路径打开命令提示符。
  • 替换以下命令中的Client_IDClient_secret并执行。
rclone authorize "onedrive" "Client_ID" "Client_secret"

接下来会弹出浏览器,要求你登录账号进行授权。授权完后命令提示符窗口会出现以下信息:

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
Log in and authorize rclone for access
Waiting for code...
Got code
Paste the following into your remote machine --->
{"access_token":"xxxxxxxxxxxxxxxxxx","expiry":"2020-02-22T21:18:39.5036298+08:00"}
<---End paste

{"access_token":"xxxxxxxxxxxxxxxxxx","expiry":"2021-02-20T11:18:39.98+08:00"} 整个内容(包含括号)就是 to­ken ,复制并保存好。

VPS上进行连接设置

安装rclone 到Linux/macOS/BSD 系统, 运行:

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

[root@q6 ~]# rclone config #运行rclone config
Current remotes:
Name Type
==== ====
googledrive 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> n # n 新建一个
name> myonedrive # 随便起个名字
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, Tencent COS, etc)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Citrix Sharefile
\ "sharefile"
9 / Dropbox
\ "dropbox"
10 / Encrypt/Decrypt a remote
\ "crypt"
11 / FTP Connection
\ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
13 / Google Drive
\ "drive"
14 / Google Photos
\ "google photos"
15 / Hubic
\ "hubic"
16 / In memory object storage system.
\ "memory"
17 / Jottacloud
\ "jottacloud"
18 / Koofr
\ "drive"
14 / Google Photos
\ "google photos"
15 / Hubic
\ "hubic"
16 / In memory object storage system.
\ "memory"
17 / Jottacloud
\ "jottacloud"
18 / Koofr
\ "koofr"
19 / Local Disk
\ "local"
20 / Mail.ru Cloud
\ "mailru"
21 / Mega
\ "mega"
22 / Microsoft Azure Blob Storage
\ "azureblob"
23 / Microsoft OneDrive
\ "onedrive"
24 / OpenDrive
\ "opendrive"
25 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
26 / Pcloud
\ "pcloud"
27 / Put.io
\ "putio"
28 / QingCloud Object Storage
\ "qingstor"
29 / SSH/SFTP Connection
\ "sftp"
30 / Sugarsync
\ "sugarsync"
31 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
32 / Transparently chunk/split large files
\ "chunker"
33 / Union merges the contents of several upstream fs
\ "union"
34 / Webdav
\ "webdav"
35 / Yandex Disk
\ "yandex"
36 / http Connection
\ "http"
37 / premiumize.me
\ "premiumizeme"
38 / seafile
\ "seafile"
Storage> 23
\ "sugarsync"
31 / Tardigrade Decentralized Cloud Storage
\ "tardigrade"
32 / Transparently chunk/split large files
\ "chunker"
33 / Union merges the contents of several upstream fs
\ "union"
34 / Webdav
\ "webdav"
35 / Yandex Disk
\ "yandex"
36 / http Connection
\ "http"
37 / premiumize.me
\ "premiumizeme"
38 / seafile
\ "seafile"
Storage> 23 #选择 23 是onedrvie
** See help for onedrive backend at: https://rclone.org/onedrive/ **
OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id> #输入你的onedrvie客户端ID
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> #输入你的客户端密钥
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n #输入n
Remote config
Make sure your Redirect URL is set to "http://localhost:53682/" in your custom config.
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
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 "onedrive" -- "客户端ID" "客户端密钥" #####在本地win机器上运行该提示内容,会弹出浏览器,登录onedrive进行验证,提示成功后,在CMD中显示access_token
Then paste the result below:
result> {"access_token":"很长的一串字符","expiry":"2021-06-04T11:25:48.258+08:00"} #####从CMD中复制这些内容,贴在此处。
Choose a number from below, or type in an existing value
1 / OneDrive Personal or Business
\ "onedrive"
2 / Root Sharepoint site
\ "sharepoint"
3 / Type in driveID
\ "driveid"
4 / Type in SiteID
\ "siteid"
5 / Search a Sharepoint site
\ "search"
Your choice> 1 #选择 1 onedrive
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=字符串i1LAj8q_7pk6NCjUMURtPL0-b2UydD字符串cBv9j
Chose drive to use:> 0 #选择 0 这个网盘
Found drive 'root' of type 'business', URL: https://abcd.sharepoint.com/personal/tabc_abcd2018_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
y/n> y # 选择 y
[myonedrive]
type = onedrive
client_id = 318字符串f36d
client_secret = w0字符串duCOM
token = {"access_token":"很长的字符串","expiry":"2021-06-04T11:20:08.8+08:00"}
drive_id = b字符串V8Nj
drive_type = business
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y 选择 y
Current remotes:
Name Type
==== ====
googledrive drive #博主以前创建的googledrive
myonedrive onedrive #这次创建的onedrive网盘
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 退出rclone设置

因我已经挂载了googledrive,所以自启动挂载,名称需要换一个

apt install fuse -y #我在安装rclone,之前没装这个,死活挂载不上去,一定要装
mkdir /gd #我在根下创建里一个目录gd,你可以创建在别的位置,只是在下面设置的时候需要注意变更
wget https://zhujitips.com/sh/rcloned && nano rcloned

根据你自己的设定,ctrl+o,回车,保存退出

自启动设置

#Debian系统
apt-get install sudo -y

#设置自启
mv rcloned /etc/init.d/rcloned-onedrive
chmod +x /etc/init.d/rcloned-onedrive
update-rc.d -f rcloned defaults
bash /etc/init.d/rcloned-onedrive start

加入主机贴士TG群,了解更多主机使用信息