diff --git a/src/authenticator.rs b/src/authenticator.rs index efd2e01..5e73aa3 100644 --- a/src/authenticator.rs +++ b/src/authenticator.rs @@ -12,7 +12,7 @@ use crate::refresh::RefreshFlow; #[cfg(feature = "service_account")] use crate::service_account::{self, ServiceAccountFlow, ServiceAccountFlowOpts, ServiceAccountKey}; use crate::storage::{self, Storage, TokenStorage}; -use crate::types::{ApplicationSecret, Token, TokenInfo}; +use crate::types::{AccessToken, ApplicationSecret, TokenInfo}; use private::AuthFlow; use crate::access_token::{AccessTokenFlow}; @@ -69,7 +69,7 @@ where S::Error: Into>, { /// Return the current token for the provided scopes. - pub async fn token<'a, T>(&'a self, scopes: &'a [T]) -> Result + pub async fn token<'a, T>(&'a self, scopes: &'a [T]) -> Result where T: AsRef, { @@ -80,7 +80,7 @@ where /// Return a token for the provided scopes, but don't reuse cached tokens. Instead, /// always fetch a new token from the OAuth server. - pub async fn force_refreshed_token<'a, T>(&'a self, scopes: &'a [T]) -> Result + pub async fn force_refreshed_token<'a, T>(&'a self, scopes: &'a [T]) -> Result where T: AsRef, { diff --git a/src/lib.rs b/src/lib.rs index 405a9fe..b274277 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,4 +111,4 @@ pub use crate::service_account::ServiceAccountKey; #[doc(inline)] pub use crate::error::Error; -pub use crate::types::{ApplicationSecret, ConsoleApplicationSecret, Token}; +pub use crate::types::{AccessToken, ApplicationSecret, ConsoleApplicationSecret}; diff --git a/src/types.rs b/src/types.rs index 485e9a4..a2bfa5c 100644 --- a/src/types.rs +++ b/src/types.rs @@ -6,20 +6,15 @@ use serde::{Deserialize, Serialize}; /// Represents a token returned by oauth2 servers. All tokens are Bearer tokens. Other types of /// tokens are not supported. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] -pub struct Token { - id_token: Option, +pub struct AccessToken { access_token: Option, expires_at: Option, } -impl Token { - /// A string representation of the ID token. - pub fn id_token(&self) -> Option<&str> { - self.id_token.as_deref() - } +impl AccessToken { /// A string representation of the access token. - pub fn access_token(&self) -> Option<&str> { + pub fn token(&self) -> Option<&str> { self.access_token.as_deref() } @@ -40,18 +35,16 @@ impl Token { } } -impl From for Token { +impl From for AccessToken { fn from( TokenInfo { access_token, - id_token, expires_at, .. }: TokenInfo, ) -> Self { - Token { + AccessToken { access_token, - id_token, expires_at, } }