Dropbox OAuth
JsWorkflows provides a platform-managed Dropbox OAuth app — you do not need to create a Dropbox app or provide credentials.
Available scopes
Section titled “Available scopes”| Resource | Operation | Scope |
|---|---|---|
| Files | Read & write files | files.content.read, files.content.write |
Connecting
Section titled “Connecting”- Go to OAuth Connections → Add Connection → Dropbox.
- Select the resources and operations your workflow needs.
- Sign in with your Dropbox account and grant the requested permissions.
- Give the connection a handle (e.g.,
my-dropbox).
Access tokens are refreshed automatically when they expire.
Example — upload a file
Section titled “Example — upload a file”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, }); }}Example — download a file
Section titled “Example — download a file”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();