小白教程:世纪互联版onedrive的rclone配置

我就教教小白rclone如何配置onedrive,包括windows版和linux版的。

这里推广一下某大佬的世纪互联onedrive->点我跳转

一. 下载并配置windows版的rclone

windows下的rclone世纪互联版的下载地址->点我跳转

二. 配置windows版rclone

进入rclone配置界面的方法:

(1)下载以后重命名为rlone.exe放在C:\Windows下,打开cmd输入

rclone config

注意:如果提示需要权限,请给予权限。

(2)也可以直接win键+R,将下载的rclone.exe文件拖入cmd中,然后空格+config。

配置方法:

1、 这里要你输入一个名字,即给你的网盘起个简短的remote,以后在你调用rclone的时候输入这个name会自动识别到这个name所代表的网盘。

C:\Users\huawei>rclone config
#这里提示你是创建一个remote还是设置配置密码,还是退出,我们这里选择新建,输入n。
n) New remote
s) Set configuration password
q) Quit config
n/s/q>n
name> test

2、 这里让你选择你要绑定到上面那个name的网盘是哪种,我们选择onedrive。

...
22 / Microsoft OneDrive
   \ "onedrive"
...
Storage>

3、 世纪互联版:这里要你输入程序ID,当然也可以直接用我的,会省去大部分配置的时间,如果直接用我的继续下一步,如果自助注册的话,请跳转到第4步获取自己的应用程序,当然使用谁的应用程序都是一样的,没有任何区别。

如果使用的是我的应用程序,也同时要填入我的应用秘钥。

注:如果是国际版的OneDrive,不需要输入此项,直接回车即可。

#国际版应用ID
d8a4cf19-ee1d-4a94-90c5-2a8183848b00
#世纪互联版应用ID
7d1f0de8-3fa7-4e50-a361-8360a3a9df0b
Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>7d1f0de8-3fa7-4e50-a361-8360a3a9df0b

4、 这里让你输入程序对应的密钥,如果使用的是我的应用程序,也同时要填入我的密码。

注:如果是国际版的OneDrive,不需要输入此项,直接回车即可。也可以使用我的:

#国际版应用秘钥
.8TY[qXP--UY1EpwC0JpPJa7yopsvcie
#世纪互联版应用秘钥
?jFUTbHyeWM3F6rEDMwldTP._ymEh09[
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> ?jFUTbHyeWM3F6rEDMwldTP._ymEh09[

5、 这一步问你是不是世纪互联版的OneDrive,这里要填true

注:如果是国际版的OneDrive,不需要输入此项,直接回车即可。

OneDrive operated by 21Vianet (世纪互联).
Enter a boolean value (true or false). Press Enter for the default ("false").
is_21vianet_version> true

6、 这一步问你是否要手动修改高级选项配置,请填n。

  Edit advanced config? (y/n)
  y) Yes
  n) No
  y/n>n

7、 这一步问你是否确定你的应用程序的重定向设置到了http://localhost:53682/这里。

如果你是用的是我给你的程序,默认已经设置好了,这里就直接填入Y就好了。

如果你使用的是自己的程序,请确认你的重定向url那一项设置好了。

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
n) No
y/n>y

8、 输入y后,你的默认浏览器会弹出网页,需要你登录你的onedrive账号,同时cmd提示如下

如果你的没有弹出,请手动复制cmd里面的链接拷贝到浏览器的地址框内。

If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=xxxxxxxx#这里的网址是不一样的
Log in and authorize rclone for access
Waiting for code...

9、 登陆完毕后会提示你success!然后cmd提示如下,让你选择是onedrive还是SharePoint或者其他的,你这里就选择1。

Got code
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

10、 基本的需要关注的配置就到这里了,接下来的剩余配置大家按照提示接着选择就好了。

11、 最后一步一定要完成,就是确认这一步。

y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d>y

三. 找到配置文件

windos系统下:

#我在我的电脑上用户名是huawei,所以我的位置是C:\Users\huawei\.config\rclone
C:\Users\用户名\.config\rclone\

你会找到一个rclone.config的文件,你可以用记事本打开,查看里面的内容,这就是我们需要的配置文件了。

四. linux下配置rclone

下载rclone_linux应用程序文件

#在root下创建一个文件夹rclone,并将文件下载至/root/rclone里面
cd /root
mkdir rclone
cd rclone
wget https://yun.rw/show/1/Files/onedrive%20tools/rclone/rclone-cn2/rclone_linux
#给予权限
chmod 775 rclone_linux
#在root下创建一个文件夹.config,并创建一个空白文件,将我们的配置复制进去
cd /root
mkdir .config
cd /root/.config/
touch rclone.config
vi rclone.config
#输入i,将windows下的config文件内容复制进去,然后按ESC,然后:wq保存并退出。
这里配置文件就创建好了

如果想查看一下配置的是否有问题

#linux环境
#先进入rclone_linux的所在路径
cd /root/rclone/
#运行rclone_linux
./rclone_linux config

#如果能能找到自己的remote就证明配置的没问题
Current remotes:
Name                 Type
====                 ====
test                 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>

五.Windows使用rclone挂载onedrive或GoogleDrive:(必须安装winfsp**)

#Winfsp:挂载onedrive和GoogleDrive的所需环境软件
#安装时选择所有子配件
https://github.com/billziss-gh/winfsp/releases/download/v1.6/winfsp-1.6.20027.msi

新建记事本,将下面脚本倒数第二行的name换成你配置onedrive时输入的名字,然后修改名字成rclone.vbs、然后双击打开就行了。

Option Explicit
Dim WMIService, Process, Processes, Flag, WS
Set WMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
Set Processes = WMIService.ExecQuery("select * from win32_process")
Flag = true
for each Process in Processes
    if strcomp(Process.name, "rclone.exe") = 0 then
        Flag = false
        exit for
    end if
next
Set WMIService = nothing
if Flag then
    Set WS = Wscript.CreateObject("Wscript.Shell")
    WS.Run "rclone mount name: X: --allow-other --allow-non-empty --vfs-cache-mode writes", 0
end if

提示:如果提示以下错误,是世纪互联onedrive的Token失效了,请使用rclone重新配置。

六、linux下rclone的挂载

首先我们先要更新fuse环境

#centos
yum install -y fuse

#debian、Ubuntu
sudo apt-get install libssl-dev

然后挂载

#创建一个文件夹用于挂载
mkdir /temp

#你rclone的位置
rclone='/root/rclone/rclone_linux'

#执行挂载,yourname 替换成你前面设置的name
$rclone mount yourname: /temp &

如果你想学习使用一些指令,请移步https://rclone.org/docs

五. 如何创建自己的应用程序

有些小白总感觉用别人的应用程序不放心,即使别人说的再好也没用,那我这里就复制一下别人的所谓的自己创建应用程序的方法。仅供大家学习。

引用blog地址:https://blog.kieng.cn/2067.html

地址:https://portal.azure.cn/,登录完成后按下面步骤进行

1、 左侧Azure Active Directory->应用注册->新注册.

2、 名称部分:随便写->受支持的账户类型:任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户

  —重定向 URI (可选):`http://localhost:53682`—注册

3、 应用程序(客户端) ID

4、 获取密匙:左侧证书和密码—

  右侧客户端密码部分:+新客户端密码

说明:自己填写—截止日期:2 年内—添加

5、 左侧 API 权限—

添加权限
Microsoft Graph
委托的权限
搜索并勾选下面 6 个权限:
Files.Read
Files.Read.All
Files.ReadWrite
Files.ReadWrite.All
offline_access
User.Read

6、 ok,到这样,就注册结束了!用记事本记录一下 ID 和密匙.

  **如果有任何问题,可以随时邮箱联系我**

<wangtaijie@midd.top>

阅读剩余
THE END