pub struct Authenticator<K: Clock> { /* private fields */ }Expand description
Acquires and caches an OAuth2 client-credentials bearer token for Unity
Catalog. Cheap to share; the token cache is internally synchronised.
Debug is implemented manually and never prints the client secret.
Implementations§
Source§impl<K: Clock> Authenticator<K>
impl<K: Clock> Authenticator<K>
Sourcepub const DEFAULT_TOKEN_PATH: &'static str = "/oidc/v1/token"
pub const DEFAULT_TOKEN_PATH: &'static str = "/oidc/v1/token"
Default OAuth token endpoint on a Databricks workspace host.
Sourcepub const DEFAULT_REFRESH_SKEW_S: i64 = 300
pub const DEFAULT_REFRESH_SKEW_S: i64 = 300
Default refresh skew: renew 5 minutes before expiry, so a long-running operation never crosses the expiry with a token it acquired just before.
Sourcepub const MAX_TOKEN_TTL_S: i64 = 3600
pub const MAX_TOKEN_TTL_S: i64 = 3600
Hard cap on how long a token is trusted, regardless of the endpoint’s
expires_in. Unity Catalog / Databricks tokens live at most ~1 hour; if a
response ever claims longer we still refresh within the hour rather than
hold a token the server has already rotated.
Sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>,
clock: K,
) -> Self
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String>, clock: K, ) -> Self
Construct an authenticator with the default token path and refresh skew.
Sourcepub fn with_token_path(self, path: impl Into<String>) -> Self
pub fn with_token_path(self, path: impl Into<String>) -> Self
Builder: override the token endpoint path.
Sourcepub fn with_refresh_skew(self, seconds: i64) -> Self
pub fn with_refresh_skew(self, seconds: i64) -> Self
Builder: override how far ahead of expiry the token is refreshed.
Larger values refresh more eagerly (safer for long operations, at the cost of a few extra token exchanges); it is clamped to at least 0.