pub struct Token { /* private fields */ }
Expand description
Represents an access token. All access tokens are Bearer tokens.
Tokens should not be cached, the AuthenticationManager
handles the correct caching
already. Tokens are cheap to clone.
The token does not implement Display
to avoid accidentally printing the token in log
files, likewise Debug
does not expose the token value itself which is only available
using the Token::as_str
method.
Implementations§
source§impl Token
impl Token
sourcepub fn has_expired(&self) -> bool
pub fn has_expired(&self) -> bool
Define if the token has has_expired
This takes an additional 30s margin to ensure the token can still be reasonably used instead of expiring right after having checked.
Note: The official Python implementation uses 20s and states it should be no more than 30s. The official Go implementation uses 10s (0s for the metadata server). The docs state, the metadata server caches tokens until 5 minutes before expiry. We use 20s to be on the safe side.
sourcepub fn expires_at(&self) -> DateTime<Utc>
pub fn expires_at(&self) -> DateTime<Utc>
Get expiry of token, if available
Trait Implementations§
source§impl<'de> Deserialize<'de> for Token
impl<'de> Deserialize<'de> for Token
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Token
impl PartialEq for Token
impl Eq for Token
impl StructuralPartialEq for Token
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.