pub trait AuthHeaderProvider: Send + Sync {
// Required method
fn auth_header<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, String)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Pluggable authentication-header provider for OpenAI-compatible drivers.
When set on an OpenAIProtocolChatDriver via
OpenAIProtocolChatDriver::with_auth_provider, the driver calls
AuthHeaderProvider::auth_header before each request and applies the
returned (name, value) header instead of the default api-key / bearer
logic keyed on the host.
This lets a driver authenticate with short-lived, refreshable tokens —
e.g. Microsoft Entra ID (OAuth) bearer tokens for Azure AI Foundry — without
the generic protocol driver having to know the auth scheme. The provider is
responsible for caching and refreshing tokens; auth_header is awaited once
per HTTP attempt, so it should be cheap on the cached path.
Required Methods§
Sourcefn auth_header<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, String)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn auth_header<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(String, String)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the (header_name, header_value) pair to apply for
authentication, refreshing any cached credential as needed. Returning
Err aborts the request before it is sent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".