pub fn auth_request<T>(api_key: &str, body: T) -> Result<Request<T>, Error>Expand description
Wrap a request body with Bearer API key authentication metadata.
All PCS External API calls require an API key in the Authorization header.
This helper creates a tonic::Request<T> with the key pre-attached.
§Errors
Returns Error::InvalidApiKey if api_key contains characters that are
not valid HTTP header values (CR, LF, NUL, non-visible ASCII). The previous
parse().ok() path silently sent the request without auth, surfacing as a
confusing Unauthenticated from PCS instead of a local config error.
§Example
let req = auth_request("pk_live_abc123", ExtGetOrCreateDmReq {
target_ppnum: "77712345678".into(),
})?;