pub struct GetAccessTokenResponse {
pub access_token: String,
pub refresh_token: String,
pub expires_in: Option<u64>,
}Expand description
Represents the Twitch API response to POST /oauth2/token API requests.
Provided as a convenience for your own implementations, as you will typically need to parse this response during the process of getting the inital token after user authorization has been granted.
Includes a impl From<GetAccessTokenResponse> for UserAccessToken for simple
conversion to a UserAccessToken:
let json_response = r#"{"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxx","expires_in":14346,"refresh_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","scope":["user_read"],"token_type":"bearer"}"#;
let decoded_response: GetAccessTokenResponse = serde_json::from_str(json_response).unwrap();
let user_access_token: UserAccessToken = UserAccessToken::from(decoded_response);Fields§
§access_token: StringOAuth access token
refresh_token: StringOAuth refresh token
expires_in: Option<u64>Specifies the time when this token expires (number of seconds from now). None if this token
never expires.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GetAccessTokenResponse
impl<'de> Deserialize<'de> for GetAccessTokenResponse
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
Source§impl From<GetAccessTokenResponse> for UserAccessToken
Available on crate feature __refreshing-token only.
impl From<GetAccessTokenResponse> for UserAccessToken
Available on crate feature
__refreshing-token only.Source§fn from(response: GetAccessTokenResponse) -> Self
fn from(response: GetAccessTokenResponse) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for GetAccessTokenResponse
impl RefUnwindSafe for GetAccessTokenResponse
impl Send for GetAccessTokenResponse
impl Sync for GetAccessTokenResponse
impl Unpin for GetAccessTokenResponse
impl UnwindSafe for GetAccessTokenResponse
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 more