pub struct OAuth2Provider { /* private fields */ }Expand description
Provider for OAuth 2.0 client-credentials authentication.
On each request, ensures a valid cached access token (fetching one from the
token endpoint via the client_credentials grant when missing or expired)
and injects it as an Authorization: Bearer <token> header.
The client secret and cached tokens are zeroized on drop to prevent lingering sensitive data in memory.
Implementations§
Source§impl OAuth2Provider
impl OAuth2Provider
Sourcepub fn new(
token_endpoint: String,
client_id: String,
client_secret: String,
scope: Option<String>,
) -> Self
pub fn new( token_endpoint: String, client_id: String, client_secret: String, scope: Option<String>, ) -> Self
Create a new OAuth 2.0 client-credentials auth provider.
token_endpoint is the full URL of the OAuth 2.0 token endpoint.
scope is optional and sent as the scope form parameter when present.
Trait Implementations§
Source§impl AuthProvider for OAuth2Provider
impl AuthProvider for OAuth2Provider
Source§fn apply<'life0, 'async_trait>(
&'life0 self,
request: RequestBuilder,
) -> Pin<Box<dyn Future<Output = EveryMapResult<RequestBuilder>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn apply<'life0, 'async_trait>(
&'life0 self,
request: RequestBuilder,
) -> Pin<Box<dyn Future<Output = EveryMapResult<RequestBuilder>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Modifies the request builder to include necessary authentication credentials.
Auto Trait Implementations§
impl !Freeze for OAuth2Provider
impl !RefUnwindSafe for OAuth2Provider
impl !UnwindSafe for OAuth2Provider
impl Send for OAuth2Provider
impl Sync for OAuth2Provider
impl Unpin for OAuth2Provider
impl UnsafeUnpin for OAuth2Provider
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
Mutably borrows from an owned value. Read more