If you want to mount a OneDrive directory using DavFS, you might need to keep the cookies up to date.
This is an extension to help you do that. To use it:
- Install the extension.
- From the Firefox Addon page
- From an XPI at Github releases
- Building yourself and install in
about:debugging. See the "Developing" section below.
- Navigate to any OneDrive directory in the browser
- Click the "cookie" icon in the address bar
- Copy the resulting line to your
/etc/davfs2/dsvfs2.conffile - Mount the drive.
You will know when it's time to do it again when mounting fails with
403 FORBIDDEN.
This is what it looks like:
You need the following OneDrive details:
USERNAME: Your OneDrive username, e.g.bobPASSWORD: Your OneDrive password, e.g.hunter2DOMAIN: The Sharepoint URL, e.g.https://company-my.sharepoint.com/personal/bob_company_com/Documents(might vary depending on the service)
And the following details on your own system:
MOUNTPOINT: Where you want to mount the OneDrive driveUSER: the username on your system that should own these files
You will also need to install davfs2 using your package manager of choice.
Add a line in /etc/fstab:
https://DOMAIN.sharepoint.com/personal/USERNAME_DOMAIN/Documents MOUNTPOINT davfs rw,user,uid=USER,noauto 0 0
You can also mount with systemd, see the Arch wiki. This
allows deferring the mount until the network is ready (which is the reason for
noauto above).
Add your OneDrive credentials in the "credential line" section of
/etc/davfs2/secrets:
https://DOMAIN.sharepoint.com/personal/USERNAME_DOMAIN/Documents USERNAME PASSWORD
Make sure this file can't be read by others:
chmod 600 /etc/davfs2/secrets && chown root:root /etc/davfs2/secrets.
This should already be true, but it won't hurt to check!
Add the cookies to /etc/davfs2/davfs2.conf. The last line is what this extension
gives you. The cookies are rather long and look like base64 encoded data.
use_locks 0
[MOUNTPOINT]
add_header Cookie rtFa=FTFA_COOKIE;FedAuth=FEDAUTH_COOKIE
This is useful if you don't have admin access, or share the machine, but don't want to share the OneDrive access credentials.
Exactly as above, but you use the files ~/.davfs2/davfs2.conf
and ~/.davfs2/secrets instead of the ones in /etc. You probably will need
to create the directory /.davfs2.
Remember to chmod 600 ~/.davfs/secrets.
As far as I know, you do still need either the entry in /etc/fstab or the
systemd unit, so you still need root's support. Let me know if it's
possible to do this entirely as a normal user!
You can load the exension in Firefox via about:debugging.
To package it, use make xpi.
