dropbox
diapason.connectors.dropbox
¶
Dropbox connector — bulk file sync via the Dropbox API v2.
Uses OAuth Bearer tokens stored locally.
All network calls are isolated in module-level functions (_dropbox_api_*)
to make them trivially mockable in tests.
DropboxConnector
¶
Bases: BaseConnector
Connector that syncs files from Dropbox via the REST API v2.
Authentication is handled through Dropbox OAuth 2.0. Tokens are stored locally in a JSON credentials file.
Parameters¶
credentials_path:
Path to the JSON file where OAuth tokens are stored. Defaults to
~/.diapason/connectors/dropbox.json.
auth_url()
¶
Return a Dropbox OAuth consent URL requesting file access scopes.
Without a stored app_key, this returns the Dropbox App Console
rather than a consent URL — the same rule the Google connectors
follow. A consent URL with an empty client_id is not degraded,
it is broken: Dropbox answers invalid_request, and the user
goes looking for the fault on their own side.
Note that unlike Google, Dropbox has no entry in OAUTH_PROVIDERS:
there is no server-side /oauth/start path for it, so this URL is
the only one on offer.
disconnect()
¶
Delete the stored credentials file.
handle_callback(code)
¶
Handle the OAuth callback by persisting the authorization code.
In a full implementation this would exchange the code for tokens. For now the code is saved directly as the token value.
is_connected()
¶
Return True if a credentials file with a valid token exists.
mcp_tools()
¶
Expose three MCP tool specs for real-time Dropbox queries.
sync(*, since=None, cursor=None)
¶
Yield :class:Document objects for Dropbox files.
Lists all files recursively. Text-extractable files (.txt, .md, .csv, .py, etc.) are downloaded and stored with their content. Other files are stored as metadata-only documents.
Parameters¶
since: Not yet used (reserved for future incremental sync). cursor: Dropbox list_folder cursor from a previous sync to resume pagination.
sync_status()
¶
Return sync progress from the most recent :meth:sync call.