orgzly-revived / orgzly-android-revived

Outliner for taking notes and managing to-do lists
https://www.orgzlyrevived.com
GNU General Public License v3.0
587 stars 37 forks source link

Make WebDAV work with Microsoft OneDrive #169

Open dleslie opened 7 months ago

dleslie commented 7 months ago

Reviving this issue from the original Orgzly tracker.

Original Issue

It appears that if you try to setup OneDrive as a repository using WebDAV it fails the "Test Connection" as the OPTIONS request to the OneDrive endpoint returns a 404 with no WebDAV headers (and therefore Orgzly assumes it doesn't work).

See this for details: https://forums.zotero.org/discussion/72411/how-to-sync-zotero-files-with-onedrive-via-webdav

NB: I know that OneDrive can work with WebDAV as I can successfully connect to OneDrive via WebDAV using WinSCP by following the instructions here: https://winscp.net/eng/docs/guide_microsoft_onedrive

Could Orgzly be made to special case OneDrive URLs starting with: https://d.docs.live.net/[cid]/ and ignore this 404 response when testing the connection?

Are there any more details you need? I could provide request/response headers if that would help.


Tip: I didn't want to use my main Microsoft account password so I created an App Password to use with WebDAV. To do that:

  1. Open https://account.microsoft.com/security/ and turn on Two-step verification
  2. Open https://account.live.com/proofs/manage/additional and create an app password (The App Passwords section only appears if Two Step verification is on)

Sam Hasler's Initial Response

I think I'm basically asking if when the uri matches ^https://d.docs.live.net/[0-9A-Z]+/.*$ if it's possible to skip (ignore the test) here: https://github.com/orgzly/orgzly-android/blob/master/app/src/main/java/com/orgzly/android/ui/repo/webdav/WebdavRepoViewModel.kt#L27

Since I knew WinSCP could authenticate to OneDrive I went looking for how it did it.

Here's the WinSCP commit to "Support Microsoft Passport authentication to allow WebDAV access to OneDrive".

WinSCP is GNU General Public License v3.0 so there's no licence issue with looking at the code, although it's C/C++ so I'm guessing it's not going to be much direct use but might provide some pointers for things to google for.

It's possible this might be a better starting point (although it's MIT License): https://github.com/AzureAD/microsoft-authentication-library-for-java

derei commented 6 months ago

If you have direct access to OneDrive through device's file explorer, you can sync like that.

I'm using pCloud and I had it set up with webDAV, but today the european webDAV server didn't connect (was down). Having the pCloud app installed on my android device, I can access the cloud storage directly from native file explorer. So, I used the Browse feature in Orgzly Revived to set my cloud sync folder. I set it up like this for both my tablet and phone, and it works fine. The advantage is the login credentials are managed by Android, not the app, and I don't have the webDAV limitations.

Maybe is worth to check if you can do the same with OneDrive.