rusty_dropbox_sdk
Unofficial Rust SDK for the Dropbox HTTP v2 API. Async-first on reqwest,
batteries-included: built-in OAuth refresh, retries on 429 / 5xx, and
streaming up- and downloads. Both async and sync are available on every
endpoint.
Status
0.8.x — usable in real workloads (246 mocked tests + a live integration
suite); the public surface may still see breaking changes before 1.0. Not
affiliated with Dropbox. Another community SDK lives at
dropbox/dropbox-sdk-rust.
Why this crate
- Zero-config HTTP —
Client::new(token)and you're going. NoHttpClienttrait to implement. - OAuth refresh built in —
Client::with_refresh(...)plusclient.call(|token| ...)auto-refreshes when expired and replays once on a 401. - Automatic retries on 429 and 5xx with exponential backoff, baked into the request macro.
- Streaming helpers —
download_streamreturns afutures::Stream<Item = Bytes>;chunked_upload::upload_large_filelifts the 150 MiB single-request cap. - Sync and async on every Request — call
.call().awaitor.call_sync()from the same struct. No feature toggling. - Typed per-endpoint errors — downcast
anyhow::ErrortoTypedError<E>(e.g.TypedError<LookupError>) and match the variant. - Stone-spec naming preserved across the 11 namespaces — types map 1:1 to the Dropbox IDL.
Install
[]
= "0.8"
= { = "1", = ["full"] }
MSRV: 1.75.
Quick start
use api;
use Service;
use Client;
async
Authentication
Two ways to construct a client:
use ;
// 1. Bring your own short-lived access token. No refresh — once it expires
// every request returns 401 until you build a new client.
let _client = new;
// 2. Auto-refreshing client. Pass the OAuth app's client_id, client_secret,
// and a long-lived refresh token (acquired via auth::exchange_code with
// offline=true). client.call(...) will refresh + replay on 401.
let _client = with_refresh;
Coverage
Implemented and tested namespaces:
account— set profile photoauth— OAuth code exchange, refresh, token revokecheck—appanduserhealth probescontacts— manual contactsfile_properties— properties + templates (Stone-IDL naming)file_requests— create, get, list, count, deletefiles— all v2 endpoints (copy, move, delete, download, upload, upload_session/*, list_folder, search, tags, lock_file, paper, etc.)openid—userinfosharing— folders, file members, shared links, inviteesusers— account, current account, space usage, features
Out of scope today: team-admin endpoints (team* namespaces).
Examples
Runnable end-to-end programs live under examples/. Each
reads credentials from environment variables and silently skips when they
aren't set, so feel free to run any of them with no setup.
DROPBOX_TOKEN=<your-token> cargo
DROPBOX_TOKEN=<your-token> cargo
DROPBOX_TOKEN=<your-token> cargo
DROPBOX_TOKEN=<your-token> cargo
DROPBOX_ACCESS_TOKEN=... DROPBOX_CLIENT_ID=... DROPBOX_CLIENT_SECRET=... \
DROPBOX_REFRESH_TOKEN=...
A few inline recipes for the most-asked questions:
use download_stream;
use StreamExt;
use AsyncWriteExt;
async
use WriteMode;
use ;
use File;
async
use ;
use LookupError;
use Service;
# async
Every request implements both call() and call_sync():
use api;
use Service;
Feature flags
test-utils— pulls inmockitoand exposes the per-test ephemeral mock-server helpers used by the SDK's own test suite. Not needed for normal use; default builds skip it entirely.
Running tests
Integration tests against the live Dropbox API live in
tests/live_dropbox.rs and are env-gated — they
silently no-op without DROPBOX_TEST_TOKEN. Run them explicitly with:
DROPBOX_TEST_TOKEN=<your-token> cargo
Contributing
Issues and PRs welcome. Please follow the standard GitHub flow.
License
GPL-3.0-only. See LICENSE.