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
-
Go to App Console for your Dropbox account.
-
Click Create App
-
Select Scoped access
-
Select Full Dropbox
-
Name your app, click the checkbox that you agree to the terms of service, then click Create App.
Creating a Dropbox App Service Token
-
Go to App Console for your Dropbox account.
-
Select your app from the list.
3.Switch to the Permissions tab.
-
Scroll down to the Files and Folders section. Check the boxes for files.content.read and files.content.write
:::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.
::: 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.
-
Click Generate under Generated Access Token
-
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.
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,
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.
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,
Paste the curl command in the textbox and this window will pop up
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.
Using this in Workflows
Dropbox templates will now require the app key, app secret, access token, and refresh token.
These 4 things can be saved in a Custom credential group for ease of use in the future. How-To: Creating and Managing Credentials