pub struct OAuthClientConfig {
pub token_endpoint: Option<Url>,
pub issuer_url: Option<Url>,
pub client_id: String,
pub client_secret: SecretString,
pub scopes: Vec<String>,
pub auth_method: ClientAuthMethod,
pub extra_headers: Vec<(String, String)>,
pub refresh_offset: Duration,
pub jitter_max: Duration,
pub min_refresh_period: Duration,
pub default_ttl: Duration,
pub http_config: Option<HttpClientConfig>,
}Expand description
Configuration for an outbound OAuth2 client credentials flow.
Exactly one of token_endpoint or
issuer_url must be set. Call
validate to enforce this constraint.
Debug is manually implemented to redact client_secret.
Fields§
§token_endpoint: Option<Url>Direct token endpoint URL (mutually exclusive with issuer_url).
issuer_url: Option<Url>OIDC issuer URL for discovery (mutually exclusive with token_endpoint).
The actual token endpoint is resolved via
{issuer_url}/.well-known/openid-configuration.
client_id: StringOAuth2 client identifier.
client_secret: SecretStringOAuth2 client secret (redacted in Debug output).
scopes: Vec<String>Requested scopes (normalized once, stable order).
auth_method: ClientAuthMethodHow client credentials are transmitted to the token endpoint.
extra_headers: Vec<(String, String)>Extra headers attached to every token request (vendor quirks).
refresh_offset: DurationHow far before expiry the token should be refreshed (default: 30 min).
jitter_max: DurationMaximum random jitter added to the refresh offset (default: 5 min).
min_refresh_period: DurationMinimum period between consecutive refresh attempts (default: 10 s).
default_ttl: DurationFallback TTL when the token endpoint omits expires_in (default: 5 min).
http_config: Option<HttpClientConfig>Override for the internal HTTP client configuration.
When None,
HttpClientConfig::token_endpoint()
is used.
Implementations§
Source§impl OAuthClientConfig
impl OAuthClientConfig
Sourcepub fn validate(&self) -> Result<(), TokenError>
pub fn validate(&self) -> Result<(), TokenError>
Validate that the configuration is self-consistent.
§Errors
Returns TokenError::ConfigError if:
- both
token_endpointandissuer_urlare set, or - neither is set.
Trait Implementations§
Source§impl Clone for OAuthClientConfig
impl Clone for OAuthClientConfig
Source§impl Debug for OAuthClientConfig
Debug redacts client_secret to prevent accidental exposure in logs.
impl Debug for OAuthClientConfig
Debug redacts client_secret to prevent accidental exposure in logs.
Auto Trait Implementations§
impl !Freeze for OAuthClientConfig
impl RefUnwindSafe for OAuthClientConfig
impl Send for OAuthClientConfig
impl Sync for OAuthClientConfig
impl Unpin for OAuthClientConfig
impl UnsafeUnpin for OAuthClientConfig
impl UnwindSafe for OAuthClientConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
Source§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read moreSource§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
Source§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read moreSource§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more