pub struct StaticTokenProvider {
pub token: SensitiveString,
}Expand description
A fixed token, from an environment variable say. It prints as [REDACTED], so a {:?}
of the provider — or of anything holding one — cannot put the token in a log.
Fields§
§token: SensitiveStringThe token every request goes out with.
Implementations§
Source§impl StaticTokenProvider
impl StaticTokenProvider
Sourcepub fn new(token: impl Into<SensitiveString>) -> StaticTokenProvider
pub fn new(token: impl Into<SensitiveString>) -> StaticTokenProvider
A provider that hands out token and nothing else.
Trait Implementations§
Source§impl Clone for StaticTokenProvider
impl Clone for StaticTokenProvider
Source§fn clone(&self) -> StaticTokenProvider
fn clone(&self) -> StaticTokenProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StaticTokenProvider
impl Debug for StaticTokenProvider
Source§impl TokenProvider for StaticTokenProvider
impl TokenProvider for StaticTokenProvider
Source§fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The token to send, asked for on every request. A provider that renews of its own
accord — handing over a new token ahead of the old one’s expiry, as OAuth libraries
do — need do nothing more: the client takes a token other than the one it last
signed with for the renewal it is, so a 401 on the old token is answered by resending
with the new one, and
refresh is not asked.Source§fn refresh<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn refresh<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asked once when a request is answered with 401. Answer
true when the next
access_token will hand out renewed credentials, and the request is sent again.
Either answer is for every request signed with the credentials that earned the 401,
not only the one that asked: a true resends them all on the new credentials, and
a false fails them all, so an outage at the token’s issuer costs one call per set
of credentials. A request signed after a false asks again. Not asked for a 401 on
a token this provider has already replaced — one access_token no longer hands out,
whether or not the replacement has signed anything yet — since that is a renewal
already made: the request is resent with the replacement, and a rotating refresh
token the provider was just issued is not spent again over the top of it.Auto Trait Implementations§
impl Freeze for StaticTokenProvider
impl RefUnwindSafe for StaticTokenProvider
impl Send for StaticTokenProvider
impl Sync for StaticTokenProvider
impl Unpin for StaticTokenProvider
impl UnsafeUnpin for StaticTokenProvider
impl UnwindSafe for StaticTokenProvider
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