pub struct AccessTokenProvider { /* private fields */ }Expand description
Hands out a valid access token, refreshing when needed.
Connectors depend on this rather than on TokenStore, so nothing outside this
type has to reason about expiry.
Implementations§
Source§impl AccessTokenProvider
impl AccessTokenProvider
pub fn new( connector: ConnectorId, flow: AuthorizationFlow, tokens: TokenStore, clock: Arc<dyn Clock>, ) -> Self
Sourcepub async fn access_token(&self, account: &AccountId) -> Result<Secret>
pub async fn access_token(&self, account: &AccountId) -> Result<Secret>
A usable access token for account.
Fails with Authentication when the account has never been connected, or when
the token expired and cannot be refreshed — both mean the user has to act.
Sourcepub async fn force_refresh(&self, account: &AccountId) -> Result<Secret>
pub async fn force_refresh(&self, account: &AccountId) -> Result<Secret>
Force a refresh, e.g. after a 401 from an API that expires tokens early.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AccessTokenProvider
impl !RefUnwindSafe for AccessTokenProvider
impl !UnwindSafe for AccessTokenProvider
impl Send for AccessTokenProvider
impl Sync for AccessTokenProvider
impl Unpin for AccessTokenProvider
impl UnsafeUnpin for AccessTokenProvider
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