pub enum Auth {
ApiKey(String),
BearerToken(String),
SdkToken(String),
}Expand description
Authentication method for REST API requests.
Debug is implemented manually to redact the secret value — printing
an Auth (directly or via tracing::debug!(?config)) emits
Auth::ApiKey(***) instead of the raw token, preventing accidental
secret leakage to logs.
Variants§
ApiKey(String)
API Key authentication (X-API-KEY header)
BearerToken(String)
Bearer token authentication (Authorization: Bearer header)
SdkToken(String)
SDK token authentication (X-SDK-TOKEN header)
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn apply_to_request(&self, request: Request) -> Request
pub fn apply_to_request(&self, request: Request) -> Request
Apply authentication to a ureq request
Sourcepub fn from_env() -> Result<Auth, MarketDataError>
pub fn from_env() -> Result<Auth, MarketDataError>
Resolve authentication from the process environment.
Probes the variables FUGLE_API_KEY, FUGLE_BEARER_TOKEN, and
FUGLE_SDK_TOKEN in that order and returns the first non-empty
match wrapped in the corresponding Auth variant. Empty strings are
treated as unset.
§Errors
Returns MarketDataError::ConfigError when none of the three
variables is set to a non-empty value.
§Example
use marketdata_core::Auth;
// FUGLE_API_KEY=my-key cargo run
let auth = Auth::from_env().expect("set FUGLE_API_KEY");