> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Dropbox Content

> Client-mode REST API connectors for Dropbox: upload shift reports, batch records and alarm snapshots from MQTT as files, download recipes and configs, watch folders for new files with a cursor and longpoll, search, copy, move to archive, restore revisions, save URLs, tag files, and share them with temporary links, shared links and file requests

Technical Preview

## Overview

Client-mode REST API connectors for Dropbox: upload shift reports, batch records and alarm snapshots from MQTT as files, download recipes and configs, watch folders for new files with a cursor and longpoll, search, copy, move to archive, restore revisions, save URLs, tag files, and share them with temporary links, shared links and file requests.

This is one of the templates in the Dropbox REST API app (`dropbox`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector). See [Dropbox](/latest/lot-language/routes/rest-api-apps/dropbox) for the package overview.

> [!NOTE]
>
> Not yet verified against the live vendor API: No Dropbox access token (DROPBOX\_ACCESS\_TOKEN, or DROPBOX\_REFRESH\_TOKEN + DROPBOX\_APP\_KEY + DROPBOX\_APP\_SECRET), so no authenticated read and no upload could run. Without a token Dropbox named the function for all 36 Bearer events (400 'Error in call to API function "\<fn>": Invalid authorization value') while the same path + '\_zz' answered 404, all 36 Bearer events answered 401 invalid\_access\_token to a dummy token, and the token-less longpoll and oauth2/token calls were validated live (dummy cursor / bad client rejected with 400).

## Auth

* **schemes**: \["Authorization: Bearer \{value.json.access\_token} on every DropboxRestApi and DropboxContentRestApi event except OAuthTokenRefresh (OAuth 2.0 access token of a scoped Dropbox app; short-lived, expires\_in 14400 s)", "OAuthTokenRefresh: POST [https://api.dropboxapi.com/oauth2/token](https://api.dropboxapi.com/oauth2/token), application/x-www-form-urlencoded \{value.json.form} = grant\_type=refresh\_token\&refresh\_token=...\&client\_id=\<app key>\&client\_secret=\<app secret>, no Authorization header", "FolderLongpoll (notify host): no Authorization header (Dropbox answers 400 'Your request includes an Authorization header, but this function does not use it.')"]
* **secrets**: \["DROPBOX\_ACCESS\_TOKEN", "DROPBOX\_REFRESH\_TOKEN", "DROPBOX\_APP\_KEY", "DROPBOX\_APP\_SECRET"]
* **scopes**: \["account\_info.read", "file\_requests.read", "file\_requests.write", "files.content.read", "files.content.write", "files.metadata.read", "files.metadata.write", "sharing.read", "sharing.write"]
* **note**: Inject secrets with a LoT action (GET SECRET); never retain topics that carry the token, refresh token or app secret; restrict storage/dropbox/oauth/# with ACLs (the refresh response carries the new access token). Authorise once with token\_access\_type=offline to get a refresh token. App folder apps see only /Apps/\<app>/.

Auth headers used by the template: `Authorization: Bearer {value.json.access_token}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Dropbox Content connector | no |
| `BaseUrl` | string | Dropbox Content base URL without trailing slash (e.g. [https://content.dropboxapi.com](https://content.dropboxapi.com)) | yes |

`BASE_ADDRESS` default: `https://content.dropboxapi.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `FileUpload` | POST | `/2/files/upload` | `storage/dropbox/files/upload` | `storage/dropbox/files/upload/response` | `access_token`, `arg`, `content` |
| `FileDownload` | GET | `/2/files/download` | `storage/dropbox/files/download` | `storage/dropbox/files/download/response` | `access_token`, `arg` |
| `SharedLinkFileGet` | GET | `/2/sharing/get_shared_link_file` | `storage/dropbox/shared-links/file/get` | `storage/dropbox/shared-links/file/get/response` | `access_token`, `arg` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode DROPBOX_CONTENT"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE DropboxContentRestApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://content.dropboxapi.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '120'
        WITH DEFAULT_CONTENT_TYPE "application/octet-stream"
    ADD EVENT FileUpload
        WITH SOURCE_TOPIC "storage/dropbox/files/upload"
        WITH DESTINATION_TOPIC "storage/dropbox/files/upload/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/2/files/upload"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Dropbox-API-Arg" "{value.json.arg}"
            ADD "Content-Type" "application/octet-stream"
        WITH BODY "{value.json.content}"
    ADD EVENT FileDownload
        WITH SOURCE_TOPIC "storage/dropbox/files/download"
        WITH DESTINATION_TOPIC "storage/dropbox/files/download/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/2/files/download"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Dropbox-API-Arg" "{value.json.arg}"
    ADD EVENT SharedLinkFileGet
        WITH SOURCE_TOPIC "storage/dropbox/shared-links/file/get"
        WITH DESTINATION_TOPIC "storage/dropbox/shared-links/file/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/2/sharing/get_shared_link_file"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "Authorization" "Bearer {value.json.access_token}"
            ADD "Dropbox-API-Arg" "{value.json.arg}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `FileUpload` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'storage/dropbox/files/upload/response' &
mosquitto_pub -t 'storage/dropbox/files/upload' -m '{"access_token": "<access_token>", "arg": "<arg>", "content": "<content>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.