pub struct TokenClientBuilder { /* private fields */ }Expand description
Builder for TokenClient. Obtain one via TokenClient::builder.
Implementations§
Source§impl TokenClientBuilder
impl TokenClientBuilder
Sourcepub fn client_id(self, client_id: impl Into<String>) -> Self
pub fn client_id(self, client_id: impl Into<String>) -> Self
Sets the client identifier (required).
Sourcepub fn client_secret(self, client_secret: impl Into<String>) -> Self
pub fn client_secret(self, client_secret: impl Into<String>) -> Self
Sets the client secret. Omit (or pass an empty string) for a public
client (authorization code grant), which is then identified by
client_id in the request body.
Sourcepub fn token_endpoint(self, token_endpoint: impl Into<String>) -> Self
pub fn token_endpoint(self, token_endpoint: impl Into<String>) -> Self
Sets the token endpoint URL (required).
Sourcepub fn auth_method(self, method: ClientAuthMethod) -> Self
pub fn auth_method(self, method: ClientAuthMethod) -> Self
Selects the client authentication method (RFC 6749 §2.3). The default is
ClientAuthMethod::ClientSecretBasic.
Sourcepub fn extra_param(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_param( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a single extra form parameter for provider-specific extensions
(e.g. an RFC 8707 resource or an audience on a grant that does not
model them). Reserved grant/auth parameters are never overridden.
Extras are client-wide, so they apply to every grant this client
performs. token_exchange additionally owns requested_token_type,
resource, and audience — it takes those from its
TokenExchangeRequest — and fails with IdentityError::Validation
rather than silently ignoring an extra that names one of them. Keys are
compared case-insensitively and ignoring surrounding whitespace.
Sourcepub fn extra_params(self, params: HashMap<String, String>) -> Self
pub fn extra_params(self, params: HashMap<String, String>) -> Self
Adds multiple extra form parameters. See extra_param.
Sourcepub fn http_client(self, client: HttpClient) -> Self
pub fn http_client(self, client: HttpClient) -> Self
Uses client for token requests instead of a default
reqwest::Client, letting callers share a connection pool or supply
custom transport configuration (CC-006).
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Bounds each token request with a per-request timeout. A non-positive duration is ignored and the default (30s) is retained.
Sourcepub fn allow_http(self, allow: bool) -> Self
pub fn allow_http(self, allow: bool) -> Self
Permits an http:// token endpoint, which is otherwise rejected.
Intended for local development and integration tests against non-TLS
providers; do not enable in production.
Sourcepub fn build(self) -> Result<TokenClient>
pub fn build(self) -> Result<TokenClient>
Builds the TokenClient.
§Errors
IdentityError::Configuration if client_id or token_endpoint is
missing or empty (AC-6).