Apex · Integration · Salesforce

Dropbox Integration with Salesforce

Hi All,

Today I will show you how to copy files to Dropbox from Salesforce using Dropbox integration.

You don’t need to buy costly AppExchange apps or services like Zapier to do this. We will show you how to do this with a simple Apex class.

First of all, we need is a Dropbox account and a Salesforce org with which we will integrate with.

If you don’t have a Dropbox account, you can get one at https://www.dropbox.com/. We have one already, so we won’t be signing up again.

Dropbox SignUp page

Fill up the form, and you will get your Dropbox account.

Now, go to the developer section of Dropbox. To do so type https://www.dropbox.com/developers in the URL and press Enter. Here we will be creating a Dropbox app that will act as a listener between the Salesforce org and the Dropbox account.

Dropbox developer page

Click on Create your app tab to start creating the app.

Screen Shot 2017-06-28 at 9.55.19 PM
Create app page in Dropbox

On the next page, select Dropbox API, and access as Full Dropbox. Give a name to your app and click on Create app button.

(Refer to the image below to create the app)

Screen Shot 2017-06-28 at 9.58.05 PM
App settings

After the app is created, there are a few more settings you need to do to proceed. Keep the App key and App secret handy. You have to update the Redirect URIs in the OAuth 2 section later on.

Screen Shot 2017-06-28 at 10.03.33 PM
App advanced settings

Now, create the Visualforce page from where you will be uploading the files to Dropbox. Set the URL of the visual force page in the Redirect URIs of the Dropbox app. (image below)

Screen Shot 2017-07-01 at 9.56.40 PM
Update the Redirect URI with vf page URL

Click the Dropbox login button to log in to Dropbox and authorise it to upload files to your Dropbox account.

Screen Shot 2017-07-01 at 10.08.24 PM
Click Dropbox login

Login to your Dropbox account to give authorisation.

Screen Shot 2017-07-01 at 10.10.45 PM
Login to Dropbox

Now you can see the email id of the connected Dropbox account and a file uploaded.

Select a file and Upload to Dropbox.

Screen Shot 2017-07-01 at 10.16.54 PM
Select file and Upload

public DropboxUploadController() {
connected = false;
success = false;
apiKey = ''; // this is your dropbox apikey
apiSecret = ''; // this is your dropbox api secret
redirectURI = 'https://souravmoy-dev-ed--c.ap2.visual.force.com/apex/DropboxUpload'; // url of the vf page in which the dropbox login is done
Dropbox_Account_endpoint = 'https://api.dropboxapi.com/1/account/info';
Dropbox_files_endpoint = 'https://content.dropboxapi.com/1/files_put/auto/';
Dropbox_OAuth_authorize = 'https://www.dropbox.com/1/oauth2/authorize';
Dropbox_OAuth_token = 'https://api.dropboxapi.com/1/oauth2/token';

code = ApexPages.currentPage().getParameters().get('code');
if(code != null) {
connected = true;
authorizationCode = code;

In lines 4, 5 write the App Key and App Secret of your Dropbox app.


The code in GitHub.

One thought on “Dropbox Integration with Salesforce

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s