Struct twitch_oauth2::UserToken [−][src]
pub struct UserToken { pub access_token: AccessToken, pub login: String, pub user_id: String, pub refresh_token: Option<RefreshToken>, pub never_expiring: bool, // some fields omitted }
An User Token from the OAuth implicit code flow or OAuth authorization code flow
Used for requests that need an authenticated user. See also AppAccessToken
See UserToken::builder
for authenticating the user using the OAuth authorization code flow
.
Fields
access_token: AccessToken
The access token used to authenticate requests with
login: String
Username of user associated with this token
user_id: String
User ID of the user associated with this token
refresh_token: Option<RefreshToken>
The refresh token used to extend the life of this user token
never_expiring: bool
Token will never expire
This is only true for old client IDs, like https://twitchapps.com/tmi and others
Implementations
impl UserToken
[src]
impl UserToken
[src]pub fn from_existing_unchecked(
access_token: impl Into<AccessToken>,
refresh_token: impl Into<Option<RefreshToken>>,
client_id: impl Into<ClientId>,
client_secret: impl Into<Option<ClientSecret>>,
login: String,
user_id: String,
scopes: Option<Vec<Scope>>,
expires_in: Option<Duration>
) -> UserToken
[src]
pub fn from_existing_unchecked(
access_token: impl Into<AccessToken>,
refresh_token: impl Into<Option<RefreshToken>>,
client_id: impl Into<ClientId>,
client_secret: impl Into<Option<ClientSecret>>,
login: String,
user_id: String,
scopes: Option<Vec<Scope>>,
expires_in: Option<Duration>
) -> UserToken
[src]Assemble token without checks.
If expires_in
is None
, we’ll assume token.is_elapsed
is always false
pub async fn from_existing<RE, C, F>(
http_client: C,
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_secret: impl Into<Option<ClientSecret>>
) -> Result<UserToken, ValidationError<RE>> where
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F,
F: Future<Output = Result<HttpResponse, RE>>,
[src]
pub async fn from_existing<RE, C, F>(
http_client: C,
access_token: AccessToken,
refresh_token: impl Into<Option<RefreshToken>>,
client_secret: impl Into<Option<ClientSecret>>
) -> Result<UserToken, ValidationError<RE>> where
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F,
F: Future<Output = Result<HttpResponse, RE>>,
[src]Assemble token and validate it. Retrieves login
, client_id
and scopes
If the token is already expired, this function will fail to produce a UserToken
and return ValidationError::NotAuthorized
pub fn builder(
client_id: ClientId,
client_secret: ClientSecret,
redirect_url: RedirectUrl
) -> Result<UserTokenBuilder, ParseError>
[src]
pub fn builder(
client_id: ClientId,
client_secret: ClientSecret,
redirect_url: RedirectUrl
) -> Result<UserTokenBuilder, ParseError>
[src]Create a UserTokenBuilder
to get a token with the OAuth Authorization Code
pub fn set_secret(&mut self, secret: Option<ClientSecret>)
[src]
pub fn set_secret(&mut self, secret: Option<ClientSecret>)
[src]Set the client secret
Trait Implementations
impl TwitchToken for UserToken
[src]
impl TwitchToken for UserToken
[src]fn token_type() -> BearerTokenType
[src]
fn token_type() -> BearerTokenType
[src]Get the type of token.
fn client_id(&self) -> &ClientId
[src]
fn client_id(&self) -> &ClientId
[src]Client ID associated with the token. Twitch requires this in all helix API calls
fn token(&self) -> &AccessToken
[src]
fn token(&self) -> &AccessToken
[src]Get the AccessToken for authenticating Read more
fn refresh_token<'life0, 'async_trait, RE, C, F>(
&'life0 mut self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<(), RefreshTokenError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
[src]
fn refresh_token<'life0, 'async_trait, RE, C, F>(
&'life0 mut self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<(), RefreshTokenError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
[src]Refresh this token, changing the token to a newer one
fn expires_in(&self) -> Duration
[src]
fn expires_in(&self) -> Duration
[src]Get current lifetime of token.
fn is_elapsed(&self) -> bool
[src]
fn is_elapsed(&self) -> bool
[src]Returns whether or not the token is expired. Read more
#[must_use]fn validate_token<'life0, 'async_trait, RE, C, F>(
&'life0 self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<ValidatedToken, ValidationError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
[src]
#[must_use]fn validate_token<'life0, 'async_trait, RE, C, F>(
&'life0 self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<ValidatedToken, ValidationError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: Sync + 'async_trait,
[src]Validate this token. Should be checked on regularly, according to https://dev.twitch.tv/docs/authentication#validating-requests Read more
#[must_use]fn revoke_token<'async_trait, RE, C, F>(
self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<(), RevokeTokenError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
Self: Send + 'async_trait,
[src]
#[must_use]fn revoke_token<'async_trait, RE, C, F>(
self,
http_client: C
) -> Pin<Box<dyn Future<Output = Result<(), RevokeTokenError<RE>>> + Send + 'async_trait>> where
Self: Sized,
RE: Error + Send + Sync + 'static,
C: FnOnce(HttpRequest) -> F + Send,
F: Future<Output = Result<HttpResponse, RE>> + Send,
RE: 'async_trait,
C: 'async_trait,
F: 'async_trait,
Self: Send + 'async_trait,
[src]Revoke the token. See https://dev.twitch.tv/docs/authentication#revoking-access-tokens
Auto Trait Implementations
impl RefUnwindSafe for UserToken
impl Send for UserToken
impl Sync for UserToken
impl Unpin for UserToken
impl UnwindSafe for UserToken
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
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>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
impl<T> WithSubscriber for T
[src]fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]
fn with_current_subscriber(self) -> WithDispatch<Self>
[src]Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more