Dropbox Promise
A simple Dropbox promise wrapper.
Installation
npm install --save dropbox-promise
Usage
Before starting anything you need to go create your app over at: https://www.dropbox.com/developers/apps then go ahead and grab your Key and Secret.
Include
Add the following to the top of your project (with the other dependencies):
const dropbox = require('dropbox-promise');
const key = "";
const secret = "";
const redirect_url = "";
Authentication
First you must generate a URL for the user to be redirected to.
dropbox.authenticate(key, redirect_url)
.then(function(url) {
})
.catch(function(error) {
});
When the user has authenticated, they will be returned to the callback URL supplied with an authentication code. We need to turn this into an access code.
dropbox.accessToken(key, secret, authentication_code, redirect_url)
.then(function(result) {
let access_token = result.access_token;
})
.catch(function(error) {
});
API
To use the API, you must create an API object:
let api = dropbox.api( access_token );
This gives us access to various functions. Here's an example of how to use this:
let api = dropbox.api( access_token );
api.unlink()
.then(function(result) {
})
.catch(function(error) {
});
Available APIs
api.unlink()
api.account()
api.storage()
api.createFolder(path)
api.listFolder(path, recursive, include_media_info, include_deleted, include_has_explicit_shared_members, include_mounted_folders)
api.getThumbnail(path, format, size)