Dropbox
Dropbox API requests authenticated with a Dropbox OAuth 2.0 access token.
Inserts a sensitive Authorization: Bearer header; expires_in is rejected because Dropbox has no query authentication.
Get started
cargo add reqsign --features dropbox
use reqsign::{default_context, dropbox};
// The default chain reads DBXCLI_ACCESS_TOKEN through the context environment.
let ctx = default_context();
let signer = dropbox::default_signer(ctx);
let mut req = http::Request::builder()
.method(http::Method::POST)
.uri("https://api.dropboxapi.com/2/users/get_current_account")
.body(())?
.into_parts()
.0;
// Sign in place, then send with the HTTP client you already use.
signer.sign(&mut req, None).await?;
The default source is the DBXCLI_ACCESS_TOKEN variable documented by the
official dbxcli tool. Reqsign does not read dbxcli account or team files.
For an explicit access token, use StaticCredentialProvider; for long-lived
access, replace the provider with RefreshCredentialProvider:
use reqsign::dropbox::{RefreshCredentialProvider, default_signer};
let ctx = reqsign::default_context();
let provider =
RefreshCredentialProvider::new("client-id", "client-secret", "refresh-token")?;
let signer = default_signer(ctx).with_credential_provider(provider);
The refresh provider sends the client ID and secret in the RFC 6749 form body
and uses Dropbox's fixed token endpoint unless the caller explicitly replaces
it with another trusted HTTPS endpoint. It rejects a successful token response
that omits expires_in, because Dropbox access tokens are expected to expire
and an unknown lifetime must not be cached as permanent.
Dropbox uses header authentication only. Signing adds a sensitive
Authorization: Bearer header and rejects expires_in; it never modifies the
URI or other headers. Refresh-token rotation is serialized per shared provider,
and the access-token cache belongs to Signer.
On wasm32-unknown-unknown, this provider enables Jiff's JavaScript clock.
Runtime signing requires a wasm-bindgen JavaScript host such as a browser or
Node; a bare WASM runtime without a JavaScript clock is not supported. CI
exercises the public default signer path under wasm-bindgen-test in Node.
Credentials
Default credential chain
The default signer tries these sources in order and uses the first one that yields a credential — no configuration needed when any of them is present:
- DBXCLI_ACCESS_TOKEN from the official dbxcli tool
Credential providers
Available ProvideCredential implementations. Construct any of them directly, reorder them, or compose them into your own chain — see Loading credentials:
EnvCredentialProvider— DBXCLI_ACCESS_TOKEN from the official dbxcli toolStaticCredentialProvider— Static access token with optional absolute expiryRefreshCredentialProvider— OAuth 2.0 refresh-token exchange