pub struct TokenResponse {
pub access_token: String,
pub expires_in: u64,
pub refresh_expires_in: u64,
pub refresh_token: Option<String>,
pub token_type: String,
pub session_state: Option<String>,
pub scope: Option<String>,
}Expand description
The answer of the token service (OAuth style).
The client reads it to get the new tokens. BcsHttpClient::authenticate
returns a value of this type, but builds it locally, see there.
§Examples
use brokapi_bcs_protocol::http::models::TokenResponse;
let reply = r#"{"access_token":"a","expires_in":86400,"refresh_expires_in":7776000,
"refresh_token":"r","token_type":"bearer"}"#;
let token: TokenResponse = serde_json::from_str(reply)?;
assert_eq!(token.expires_in, 86_400); // 24 hours
assert_eq!(token.refresh_token.as_deref(), Some("r"));Fields§
§access_token: StringThe access token to put in Authorization: Bearer .... A secret.
expires_in: u64Lifetime of the access token in seconds. The broker docs say 24 hours in total.
refresh_expires_in: u64Lifetime of the refresh token in seconds. The broker docs say 90 days in total.
refresh_token: Option<String>A new refresh token, if the token service rotates it. Keep it in place of the old one. None if the reply carried none.
token_type: StringType of the access token, bearer by the token service.
session_state: Option<String>Session id of the token service, if it sends one.
scope: Option<String>Scope granted to the token, if the token service sends one.
Trait Implementations§
Source§impl Clone for TokenResponse
impl Clone for TokenResponse
Source§fn clone(&self) -> TokenResponse
fn clone(&self) -> TokenResponse
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 TokenResponse
impl Debug for TokenResponse
Source§impl<'de> Deserialize<'de> for TokenResponse
impl<'de> Deserialize<'de> for TokenResponse
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 TokenResponse
impl RefUnwindSafe for TokenResponse
impl Send for TokenResponse
impl Sync for TokenResponse
impl Unpin for TokenResponse
impl UnsafeUnpin for TokenResponse
impl UnwindSafe for TokenResponse
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