pub struct Token {
pub access_token: Option<String>,
pub expires_in: Option<u64>,
pub refresh_expires_in: Option<u64>,
pub refresh_token: Option<String>,
pub token_type: Option<String>,
pub id_token: Option<String>,
pub session_state: Option<String>,
pub scope: Option<String>,
}Expand description
Represents an authentication token response typically returned by an OAuth2 / OpenID Connect authorization server.
This structure contains access credentials and metadata required to authenticate requests and manage token lifecycle, including expiration and refresh information.
All fields are optional to support partial responses from different identity providers.
§Fields
access_token— The token used to authenticate API requests.expires_in— Lifetime of the access token in seconds.refresh_expires_in— Lifetime of the refresh token in seconds.refresh_token— Token used to obtain a new access token when the current one expires.token_type— Type of the token (commonly"Bearer").id_token— OpenID Connect ID token containing user identity claims.session_state— Identifier for the authenticated session.scope— Space-separated list of granted permissions.
§Serialization
This struct supports serialization and deserialization via serde,
making it suitable for use with JSON-based authentication responses.
§Example
use rust_microservice::Token;
let token = Token {
access_token: Some("abc123".to_string()),
expires_in: Some(3600),
refresh_expires_in: Some(7200),
refresh_token: Some("refresh_abc123".to_string()),
token_type: Some("Bearer".to_string()),
id_token: None,
session_state: None,
scope: Some("openid profile email".to_string()),
};Fields§
§access_token: Option<String>§expires_in: Option<u64>§refresh_expires_in: Option<u64>§refresh_token: Option<String>§token_type: Option<String>§id_token: Option<String>§session_state: Option<String>§scope: Option<String>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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request