How to setup the Dropbox API?

Hey! @leonidas.petrou4 The best way to do this is by using Javascript SDK as I mentioned before.
As @neerja suggested, you need to create a custom plugin (you need javascript knowledge to do this).

I created a piece of javascript code that should do what you trying to do:

You can see an example here using that code: https://wjklw.bubbleapps.io/version-test/dropbox
In this example, the files are uploaded at this PUBLIC FOLDER:
https://www.dropbox.com/sh/ylaecii79u8x2aq/AACS-79eOYAh0BX1Y_87LTCOa?dl=0

Redu

4 Likes

That is awesome. Thanks @yusaney1 I really appreciate it. This is a good starting point for me as I have no Javascript experience. Do you know how to do the same thing with the difference that the file gets uploaded into the current user’s Dropbox account?

Would you also mind please sending me a link to the editor so I can see how you set it up? I assume you used the Toolbox plugin.

No Toolbox or any other external plugin. That screenshot is from plugin editor.
About your question, actually, you can upload to any Dropbox account as soon as you have the API-key. In this case, I’m using my API-key but you can change the field using dynamic value:

About the editor, even if I send you the link you will not see anything because the code that uploads is not visible (which is visible in the first screenshot).

1 Like

Great thank you @yusaney1 . So then all I’d need to figure out is how to do this in Javascript :

To get the current user’s access token. Then enter the token in as a dynamic value.

Would you agree?

Yes, but you don’t have to figure how to do it cause I already did for you (the code on the first screenshot).

You only have to copy that code in your plugin (create one from https://bubble.io/my_plugins) and set up the fields.

Thanks @yusaney1 , so I’ve managed to create the “upload_to” Element action - triggered in workflows where I added in your code. I then added the dropbox_key and dropbox_path in the fields and defined their types. I did all this in the “Elements” tab in the plugin editor. I have managed to authorise the private plugin and install it in my app. However, I think I am still missing a part of the plugin setup. Specifically, where do I define the file to be uploaded? I.e. where do I reference the file uploader / the file to be uploaded.

Add me as editor in your plugin and will check the code. yusaney@gmail.com

1 Like

I have added you as a collaborator @yusaney1 . Thank you!

For anyone interested, this was @yusaney1’s Javascript plugin solution (see screenshots below).

He was kind enough to help me get this working. This works great to upload files to one Dropbox account (the account of the generated token) but not to each user’s private Dropbox account. Unless users create their own Dropbox developer accounts, app and token which they would then input into my app. This can work, but it is not a seamless user experience and will be tough for non-technical users. So unless we use User Authorisation, this problem remains unsolved :frowning:

I can only see this solution being solved in one of two ways:

  1. The Bubble team fix the API connector to allow POST calls with user-agent flow. Any update on this @neerja? Or,
  2. Use Javascript to set up a Dropbox User Authorisation Plugin, which I have no idea how to do.

2 Likes

I think I found a way… doing some test actually…

Hi @leonidas.petrou4, as told you this morning the code uploads files using Access token. The OAuth process gets that Access token when you log-in with your Dropbox account and link’s to app-folder-project.

However, this is what you want, an OAuth sign using Javascript SDK:

You can see how it works here: https://wjklw.bubbleapps.io/version-test/dropbox2
Test it and tell me if it’s working as you want.

Redu.

2 Likes

I was able to make it work without any plugin and js sdk.
The first step is to use a link to the authorize and redirect to another page when user accept (this is the redirect uri). In this page keep it empty, but create a flow on page load that will grab the CODE from url. Call the Token endpoint to get access token, store it with user. Authenticate with access token with all other call.

3 Likes

That is exactly what I want! I can’t believe my eyes. Thank you so much! Can you please share your solution with me?

This topic was automatically closed after 70 days. New replies are no longer allowed.