Breadcrumbs

Dropbox - Authorization

To get started with any Dropbox Blueprints, you will need to create have a Dropbox app and a Service Token for that app. This Service Token is a secure way for Workflows to access Dropbox and will be required for every Dropbox Blueprint.

This service token will usually be tied directly to your user account, giving our Dropbox Blueprints access to any file you have access to.

Creating a Dropbox App

  1. Go to App Console for your Dropbox account.

  2. Click Create App

https://cdn.sanity.io/images/2xyydva6/production/dd7663267d7d1714ab9747f992cffda97d167672-2024x270.png?w=450
  1. Select Scoped access

https://cdn.sanity.io/images/2xyydva6/production/3d1629f83264a2736fa957927f08896268179d76-2294x526.png?w=450
  1. Select Full Dropbox

https://cdn.sanity.io/images/2xyydva6/production/55648afa57e00c4976385794b1c96ff4608e3a5f-2228x496.png?w=450
  1. Name your app, click the checkbox that you agree to the terms of service, then click Create App.

https://cdn.sanity.io/images/2xyydva6/production/26ad193d2b24cfcf5aabecd807db2c9d4f2cc494-2222x580.png?w=450

Creating a Dropbox App Service Token

  1. Go to App Console for your Dropbox account.

  2. Select your app from the list.

https://cdn.sanity.io/images/2xyydva6/production/2c1e7b5ba3f03d0fdab6f1653b89dc0f248bfeda-656x532.png?w=450

3.Switch to the Permissions tab.

https://cdn.sanity.io/images/2xyydva6/production/8cf13890d0e0efe43370478a1093b6fe37a4a311-894x226.png?w=450
  1. Scroll down to the Files and Folders section. Check the boxes for files.content.read and files.content.write

https://cdn.sanity.io/images/2xyydva6/production/472c385431fc606e91b017b45331538aba0a8722-1436x494.png?w=450

:::info If you're accessing files in a Team folder, you'll also need to set the following permissions.

Scroll down to the Team Scopes section. Check the boxes for teamdata.member, teamdata.teamspace and files.teammetadata.write.

https://cdn.sanity.io/images/2xyydva6/production/b7162859452b802d7f864afdad2c2b99a6a14592-1490x492.png?w=450

::: 5. Click Submit at the bottom of the screen.

6. Scroll back up to the top and change back to the Settings tab.

7. Scroll down until you reach the OAuth 2 section.

  1. Click Generate under Generated Access Token

https://cdn.sanity.io/images/2xyydva6/production/80c462bee6956ab85f62118aec2a7e3154b1e59d-398x152.png?w=450
  1. Store this Access token somewhere safe. It will be used for all of the Dropbox Blueprints.


Obtaining the Refresh Token

First you will need to obtain your apps App key and App secret located just above the OAuth2 section.


image-20260210-170542.png

The next step is to obtain an auth code to use to get a refresh token

To obtain an auth code to get the refresh token, take this URL

https://www.dropbox.com/oauth2/authorize?client_id=<APP_KEY>&token_access_type=offline&response_type=code

And replace <APP_KEY> with the actual appkey ex)

https://www.dropbox.com/oauth2/authorize?client_id=myappkey&token_access_type=offline&response_type=code

Then copy paste the url into your browser.

This will open a page that will ask you if you want to authorize access to your app,

image-20260210-194628.png


image-20260213-181614.png

Click continue and copy and then Allow, a code will then appear. Copy that for the next step (note that code is also short lived,around an hour, and single use).

This will be used as your Access Code next

Post Request

The next step is to set up a POST request to Dropbox to get the refresh token. This can be done in several ways:

  • Workflows (using the bash template)

  • Terminal

  • PostMan

The terminal shell and workflows work the same way so those two will be lumped together.

image-20260210-200457.png

The command used to get the refresh token is as follows:

curl --location --request POST 'https://api.dropboxapi.com/oauth2/token' \
-u '<APP_KEY>:<APP_SECRET>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code=<ACCESS_CODE>' \
--data-urlencode 'grant_type=authorization_code'

in this, replace <APP_KEY> with your appkey from the first step, and do the same with your app secret. Next replace <ACCESS_CODE> with the code copied from the previous step.

So it will look like this

curl --location --request POST 'https://api.dropboxapi.com/oauth2/token' \
-u 'mykey:mysecret' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code=myaccesscode' \
--data-urlencode 'grant_type=authorization_code'

In the workflow logs, if everything is valid, there will be a response with the refresh token. Save this somewhere safe.


If using a terminal, just paste that in and hit enter and you will receive a JSON body including the refresh_token .

In workflows, use the same command inside a bash template.

and the same output will appear in the logs after running.

POSTMAN

First copy the curl command above, then in Postman click the import button near the top left,

image-20260210-201111.png

Paste the curl command in the textbox and this window will pop up

image-20260210-201200.png

Click either of the import options. Under Authorization check that the username is you app key and password is your app secret. Next under Bodycheck that value for the key code is the authorization code obtained earlier. Once that is setup, double check that the URL is correct, and that it is a POST request. Hit Send and you should receive a json response with the refresh_token in it.

image-20260210-202629.png


Using this in Workflows

Dropbox templates will now require the app key, app secret, access token, and refresh token.

image-20260213-172544.png

These 4 things can be saved in a Custom credential group for ease of use in the future. How-To: Creating and Managing Credentials