Struct twitch_oauth2::tokens::AppAccessToken
source · [−]pub struct AppAccessToken {
pub access_token: AccessToken,
pub refresh_token: Option<RefreshToken>,
/* private fields */
}
Expand description
An App Access Token from the OAuth client credentials flow
Used for server-to-server requests. Use UserToken
for requests that need to be in the context of an authenticated user.
In some contexts (i.e EventSub) an App Access Token can be used in the context of users that have authenticated the specific Client ID
Fields
access_token: AccessToken
The access token used to authenticate requests with
refresh_token: Option<RefreshToken>
The refresh token used to extend the life of this user token
Implementations
sourceimpl AppAccessToken
impl AppAccessToken
sourcepub fn from_existing_unchecked(
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_id: impl Into<ClientId>,
client_secret: impl Into<ClientSecret>,
scopes: Option<Vec<Scope>>,
expires_in: Option<Duration>
) -> AppAccessToken
pub fn from_existing_unchecked(
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_id: impl Into<ClientId>,
client_secret: impl Into<ClientSecret>,
scopes: Option<Vec<Scope>>,
expires_in: Option<Duration>
) -> AppAccessToken
Assemble token without checks.
If expires_in
is None
, we’ll assume token.is_elapsed() == true
sourcepub async fn from_existing<'a, RE, C>(
http_client: &'a C,
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_secret: ClientSecret
) -> Result<AppAccessToken, ValidationError<<C as Client<'a>>::Error>> where
C: Client<'a>,
pub async fn from_existing<'a, RE, C>(
http_client: &'a C,
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_secret: ClientSecret
) -> Result<AppAccessToken, ValidationError<<C as Client<'a>>::Error>> where
C: Client<'a>,
sourcepub async fn get_app_access_token<'a, C>(
http_client: &'a C,
client_id: ClientId,
client_secret: ClientSecret,
scopes: Vec<Scope>
) -> Result<AppAccessToken, AppAccessTokenError<<C as Client<'a>>::Error>> where
C: Client<'a>,
pub async fn get_app_access_token<'a, C>(
http_client: &'a C,
client_id: ClientId,
client_secret: ClientSecret,
scopes: Vec<Scope>
) -> Result<AppAccessToken, AppAccessTokenError<<C as Client<'a>>::Error>> where
C: Client<'a>,
Generate app access token via OAuth client credentials flow
Trait Implementations
sourceimpl Clone for AppAccessToken
impl Clone for AppAccessToken
sourcefn clone(&self) -> AppAccessToken
fn clone(&self) -> AppAccessToken
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AppAccessToken
impl Debug for AppAccessToken
sourceimpl TwitchToken for AppAccessToken
impl TwitchToken for AppAccessToken
sourcefn token_type() -> BearerTokenType
fn token_type() -> BearerTokenType
Get the type of token.
sourcefn client_id(&self) -> &ClientId
fn client_id(&self) -> &ClientId
Client ID associated with the token. Twitch requires this in all helix API calls
sourcefn token(&self) -> &AccessToken
fn token(&self) -> &AccessToken
Get the AccessToken for authenticating Read more
sourcefn login(&self) -> Option<&UserNameRef>
fn login(&self) -> Option<&UserNameRef>
Get the username associated to this token
sourcefn refresh_token<'a, 'life0, 'async_trait, C>(
&'life0 mut self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<(), RefreshTokenError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn refresh_token<'a, 'life0, 'async_trait, C>(
&'life0 mut self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<(), RefreshTokenError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Refresh this token, changing the token to a newer one
sourcefn expires_in(&self) -> Duration
fn expires_in(&self) -> Duration
Get current lifetime of token.
sourcefn is_elapsed(&self) -> bool
fn is_elapsed(&self) -> bool
Returns whether or not the token is expired. Read more
sourcefn validate_token<'a, 'life0, 'async_trait, C>(
&'life0 self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<ValidatedToken, ValidationError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
Self: Sized,
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
fn validate_token<'a, 'life0, 'async_trait, C>(
&'life0 self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<ValidatedToken, ValidationError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
Self: Sized,
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
Validate this token. Should be checked on regularly, according to https://dev.twitch.tv/docs/authentication#validating-requests Read more
sourcefn revoke_token<'a, 'async_trait, C>(
self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<(), RevokeTokenError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
Self: Sized,
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
Self: Send + 'async_trait,
fn revoke_token<'a, 'async_trait, C>(
self,
http_client: &'a C
) -> Pin<Box<dyn Future<Output = Result<(), RevokeTokenError<<C as Client<'a>>::Error>>> + Send + 'async_trait>> where
Self: Sized,
C: Client<'a>,
'a: 'async_trait,
C: 'async_trait,
Self: Send + 'async_trait,
Revoke the token. See https://dev.twitch.tv/docs/authentication#revoking-access-tokens
Auto Trait Implementations
impl RefUnwindSafe for AppAccessToken
impl Send for AppAccessToken
impl Sync for AppAccessToken
impl Unpin for AppAccessToken
impl UnwindSafe for AppAccessToken
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more