Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CypherpunkSamurai/7ea215dee3a6cc740089c8b9be597f70 to your computer and use it in GitHub Desktop.

Select an option

Save CypherpunkSamurai/7ea215dee3a6cc740089c8b9be597f70 to your computer and use it in GitHub Desktop.
Making Obsidian `remotely-save/remotely-save` work on dropbox root directory

Making Obsidian remotely-save/remotely-save work on dropbox root directory

So, remotely-save is a plugin that allows saving to dropbox and onedrive and webdav. I was using it but it didn't match my workflow with dillinger. So i patched it to save vaults in the root (i.e. /) of the cloud storages.

Finding what to patch

As remotely-save is opensource i looked up the source code and found that there's a method in settings.ts that uses the plugin id.

I then used notepad3 (a notepad alternative for windows) to open the large main.js from my obsidian vault folder. I then searched for it, and sure enough it was there.

So I edited, this line:

("settings_dropbox_folder",{pluginID:this.plugin.manifest.id,vaultName:this.app.vault.getName()}

to

("settings_dropbox_folder",{pluginID:"",vaultName:this.app.vault.getName()}

Also meanwhile i also found out OneDrive was also using the same. I decided to repeat it for one drive too.

("settings_onedrive_folder",{pluginID:this.plugin.manifest.id,vaultName:this.app.vault.getName()})

to

("settings_onedrive_folder",{pluginID:"",vaultName:this.app.vault.getName()})

Making New Oath Apps for Full Drive Access

If you've used Dropbox and Oauth apps then you'll know that auth scopes are usually limited. Especially for cloud storage oauth providers restrict apps to their own directories.

So to access the root of the drive we need to give full access to the plugin. So we need a new oauth app.

Making a Dropbox Oath App

For Dropbox I had to visit Dropbox App Console and make a new app with Full Dropbox Access.

Then i visited the app scopes and gave it files and folder read write access.

Lastly i copied the api key (dropbox api key is also called client id) to a safe place.

Finding and Replacing the Keys

To patch the keys from the script we need to find the keys first.

I let my browser open the auth url, then copied the url. Usually Oauth urls have client id and redirect uri in them.

I copied it and pasted it into a online url decoder and copied the plugin's production client id from there.

Then i searched it from notepad3 and replaced it with my new app key from Dropbox App Console.

Adding the redirect url

For our app to work properly we need to add the same redirect url as the plugin. Following from the recent steps we used url decoder to obtain the client id, we also got the redirect url there.

The decoded url had a query redirect_uri=obsidian://remotely-save-cb-dropbox so obsidian://remotely-save-cb-dropbox is the redirect uri.

We simply add the same redirect uri from the Dropbox App Console.

Reloading

Now save the file from notepad3 and run obsidian. Delete data.json. Choose the cloud provider and Authenticate from an account. The synced files should now be saved in the root folder inside a folder having the vault name.

Thanks

Thanks to remotely-sync devs for the plugin, I hope the plugin adds more features :)

#!/bin/sh
# Configs
DROPBOX_CLIENT_ID=""
# Make sure to add redirect uri to your app from Console
# Replaces dropbox api id
sed -i "s/uwxv4ofkrmc4zzf/$DROPBOX_CLIENT_ID/g" main.js
# Replaces all instances of plugin's name setting
sed -Ei "s/\{pluginID\:this.plugin.manifest.id/\{pluginID\:\"\"/g" main.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment