You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/lib.rs
+1-1
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@
48
48
//!
49
49
//! ## HTTP Requests
50
50
//!
51
-
//! To enable client features with a supported http library, enable the http library feature in `twitch_oauth2`, like `twitch_oauth2 = { features = ["reqwest"], version = "0.15.1" }`.
51
+
//! To enable client features with a supported http library, enable the http library feature in `twitch_oauth2`, like `twitch_oauth2 = { features = ["reqwest"], version = "0.15.2" }`.
52
52
//! If you're using [twitch_api](https://crates.io/crates/twitch_api), you can use its [`HelixClient`](https://docs.rs/twitch_api/latest/twitch_api/struct.HelixClient.html) instead of the underlying http client.
/// Errors for [UserToken::from_refresh_token][crate::UserToken::from_refresh_token] and [UserToken::UserToken::from_existing_or_refresh_token][crate::UserToken::from_existing_or_refresh_token]
/// Create a [UserToken] from an existing active user token. Retrieves [`login`](TwitchToken::login), [`client_id`](TwitchToken::client_id) and [`scopes`](TwitchToken::scopes)
115
+
/// Creates a [UserToken] using a refresh token. Retrieves the [`login`](TwitchToken::login)and [`scopes`](TwitchToken::scopes).
116
116
///
117
-
/// If the token is already expired, this function will fail to produce a [`UserToken`] and return [`ValidationError::NotAuthorized`]
117
+
/// If an active user token is associated with the provided refresh token, this function will invalidate that existing user token.
/// Create a [UserToken] from an existing active user token. Retrieves [`login`](TwitchToken::login) and [`scopes`](TwitchToken::scopes)
138
+
///
139
+
/// If the token is already expired, this function will fail to produce a [`UserToken`] and return [`ValidationError::NotAuthorized`].
140
+
/// If you have a refresh token, you can use [`UserToken::from_refresh_token`] to refresh the token if was expired.
141
+
///
142
+
/// Consider using [`UserToken::from_existing_or_refresh_token`] to automatically refresh the token if it is expired.
118
143
///
119
144
/// # Examples
120
145
///
@@ -150,6 +175,47 @@ impl UserToken {
150
175
.map_err(|e| e.into_other())
151
176
}
152
177
178
+
/// Create a [UserToken] from an existing active user token or refresh token if the access token is expired. Retrieves [`login`](TwitchToken::login), [`client_id`](TwitchToken::client_id) and [`scopes`](TwitchToken::scopes).
179
+
///
180
+
/// # Examples
181
+
///
182
+
/// ```rust,no_run
183
+
/// use twitch_oauth2::{AccessToken, ClientId, ClientSecret, RefreshToken, UserToken};
184
+
/// // Make sure you enable the feature "reqwest" for twitch_oauth2 if you want to use reqwest
0 commit comments