> ## 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

> LoT connector for the Dropbox content host: upload files from MQTT, download files and fetch shared link files with an OAuth 2.0 access token

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](https://docs.coreflux.org/latest/connectors/rest-api-apps/dropbox.md) for the package overview.

## 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":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-connectorCode DROPBOX_CONTENT"
```

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

```lot theme={"theme":{"light":"css-variables","dark":"css-variables"},"languages":{"custom":["/languages/lot.json"]}}
DEFINE CONNECTOR 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 `-addConnector` (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":{"light":"css-variables","dark":"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](https://docs.coreflux.org/latest/connectors/rest-api/overview)
* [REST API Apps catalog](https://docs.coreflux.org/latest/connectors/rest-api-apps)


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