Skip to main content

Baidu Netdisk

Baidu Netdisk Open Platform xpan API requests authenticated with an access_token query parameter; OAuth refresh, paths, storage operations, headers, and business requests remain caller-owned.

Baidu Netdisk access_token query parameter— header signing✓ query / presign✓ WASMdocs.rs/reqsign-baidu-netdisk ↗

Removes existing access_token parameters and appends one form-encoded access_token query parameter while preserving unrelated wire query bytes and all headers. expires_in is rejected; OAuth refresh and persistence stay with the caller.

Get started​

cargo add reqsign --features baidu-netdisk
use reqsign::{baidu_netdisk, default_context};

// Supply the access token explicitly; Reqsign does not discover one.
let ctx = default_context();
let signer = baidu_netdisk::default_signer(ctx, "baidu-netdisk-access-token");

let mut req = http::Request::get(
"https://pan.baidu.com/rest/2.0/xpan/file?method=list&dir=%2Fapps%2FMyApp",
)
.body(())?
.into_parts()
.0;

// Adds access_token=<token> to the query string.
signer.sign(&mut req, None).await?;

The Baidu Netdisk Open Platform xpan APIs authenticate requests with an access_token query parameter. The signer removes any existing access_token parameter and appends one form-encoded parameter, so signing the same request again does not leave stale authentication. Existing percent escapes, parameter order, duplicate keys, empty values, literal + characters, and all headers are preserved.

Credentials​

StaticCredentialProvider accepts a token that the caller already obtained through Baidu's Open Platform authorization flow. Reqsign does not read an environment variable, a well-known credential file, or an OAuth token endpoint for Baidu Netdisk. OAuth refresh, single-use refresh-token rotation, and token persistence stay with the caller and are not implemented by this crate.

The token is a secret. Debug output for credentials and the static provider never contains it. Because the token appears in the request URI, treat signed URLs and any logs or error output that include the URI as secret-bearing material.

A token has no tracked expiry in this crate and is reused for the lifetime of the Signer. Replace the credential provider or create a new signer to use a different token. Query authentication has no separate presign lifetime here, so signing rejects expires_in.

The caller owns the API host, method, path, other query parameters, headers (including User-Agent), and request body. Do not forward a signed request to an unrelated host.

Credentials

Default credential chain

This provider has no ambient default source. Supply an explicit credential provider as described on this page.

Credential providers

Available ProvideCredential implementations. Construct any of them directly, reorder them, or compose them into your own chain — see Loading credentials: