Skip to content

Dropbox OAuth

JsWorkflows provides a platform-managed Dropbox OAuth app — you do not need to create a Dropbox app or provide credentials.

ResourceOperationScope
FilesRead & write filesfiles.content.read, files.content.write
  1. Go to OAuth Connections → Add Connection → Dropbox.
  2. Select the resources and operations your workflow needs.
  3. Sign in with your Dropbox account and grant the requested permissions.
  4. Give the connection a handle (e.g., my-dropbox).

Access tokens are refreshed automatically when they expire.

class Workflow {
async start(data, headers, api) {
const { token, error } = await api.getOAuthToken('my-dropbox');
if (error) { api.log('OAuth error:', error); return; }
await api.scheduleNextStep({
delay: 10,
action: 'uploadReport',
payload: { token, orderId: data.id, total: data.total_price },
});
}
async uploadReport({ token, orderId, total }, headers, api) {
const content = `Order ID,Total\n${orderId},${total}`;
await fetch('https://content.dropboxapi.com/2/files/upload', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/octet-stream',
'Dropbox-API-Arg': JSON.stringify({
path: `/reports/order-${orderId}.csv`,
mode: 'overwrite',
}),
},
body: content,
});
}
}
const { token } = await api.getOAuthToken('my-dropbox');
const resp = await fetch('https://content.dropboxapi.com/2/files/download', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Dropbox-API-Arg': JSON.stringify({ path: '/reports/config.json' }),
},
});
const text = await resp.text();