Most Powerful Open Source ERP

Howto integrate Dropbox

  • Last Update:2020-05-20
  • Version:001
  • Language:en

Dropbox Integration to jIO

The Dropbox's integration has been done with the Dropbox Core Api, which documentation is available here: https://www.dropbox.com/developers/core/docs

This guide will explain you how to create a Dropbox storage in jIO

Agenda:

  • Dropbox credentials retrieving process overview
  • creation of a Dropbox application
  • getting the user token
  • creating a jIO Dropbox storage
  • details about the Dropbox API.

Dropbox credentials retrieving process overview

graph explaining the Dropbox credentials retrieving process

The user connects to a Dropbox application,  and is redirected to an url you specified.

An access token is given as a parameter in the url. This token is used at the creation of the jIO Dropbox storage.

Creating a Dropbox application

Go to https://www.dropbox.com/developers/apps/create , select "Dropbox API", the type of access of the app (limited to a folder or able to all the Dropbox account) , and name your app.

screenshot showing creation of a dropbox applicationscreenshot showing an example of application creation.

You are then redirected to a page which gives you an App key. please note it.

on the same page, in the "redirect URIs" field, type the url of your jIO application. 

Getting the user token

Redirect the user to:

https://www.dropbox.com/1/oauth2/authorize?client_id=APPKEY&response_type=token&redirect_uri=REDIRURL

where APPKEY is the key you noted previously and REDIRURL the url you specified at the previous step.

There, the user logins, and is redirected to your jIO application. The user token is given as a parameter of the url like this:

http://www.jioexample.com#access_token=-TOKEN_EXAMPLE&token_type=bearer&uid=0123456789 

Create a Dropbox jIO storage.

Retrieve the token from the url with a method like this:

var start = document.URL.indexOf("access_token=") + 15);
var end = document.URL.indexOf("&", start);
var token = document.URL.slice(start, end);

Then use the jIO.createJIO method like this:

var storage = jIO.createJIO({type: "dropbox", access_token : token, root : "ROOT_MODE" });

where  ROOT_MODE is the app limitation.

If at the creation of the app, you chose to get a full access to the user's Dropbox account, root shall be "dropbox" otherwise, root shall be "sandbox".

The jIO Dropbox storage has the same methods and behavior as for DAV storage, with exceptions shown below.

Details about the Dropbox API.

For now, the putAttachement method can't upload files larger than 150MB. There is a Dropbox API call, "chunked upload", allowing files of a greater size, but this call is difficult to implement on jIO.

Due to the Dropbox API, if you do a putAttachment to an nonexistent directory, Drobpox will automatically create this directory. (and his parents directories if needed).

The removeAttachment method can delete directories, acting like the 'remove' method.

Don't forget to read the Dropbox Api documentation: for more informations: https://www.dropbox.com/developers/core/docs