Skip to content

Update to user token constructor change #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
let token = UserToken::from_existing(
reqwest_http_client,
AccessToken::new("mytoken".to_string()),
None,
None, // Client ID
None, // Client Secret
)
.await?;
let client: TwitchClient<reqwest::Client> = TwitchClient::default();
Expand Down
1 change: 1 addition & 0 deletions examples/automod_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await?;

Expand Down
1 change: 1 addition & 0 deletions examples/channel_information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await?;

Expand Down
1 change: 1 addition & 0 deletions examples/create_follower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await?;

Expand Down
1 change: 1 addition & 0 deletions examples/get_channel_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions examples/get_moderation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await?;

Expand Down
1 change: 1 addition & 0 deletions examples/get_streams_and_chatters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ async fn main() {
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions examples/modify_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.map(AccessToken::new)
.expect("Please set env: TWITCH_TOKEN or pass token as first argument"),
None,
None,
)
.await?;

Expand Down
6 changes: 3 additions & 3 deletions src/helix/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = GetCheermotesRequest::builder()
Expand Down Expand Up @@ -56,7 +56,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_cheermotes::GetCheermotesRequest::builder().build();
/// let response: Vec<get_cheermotes::Cheermote> = client.req_get(request, &token).await?.data;
/// # Ok(())
Expand Down Expand Up @@ -479,7 +479,7 @@ pub mod get_cheermotes {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_bits_leaderboard::GetBitsLeaderboardRequest::builder().build();
/// let response: get_bits_leaderboard::BitsLeaderboard = client.req_get(request, &token).await?.data;
/// # Ok(())
Expand Down
8 changes: 4 additions & 4 deletions src/helix/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = GetChannelInformationRequest::builder()
Expand Down Expand Up @@ -61,7 +61,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_channel_information::GetChannelInformationRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -229,7 +229,7 @@ pub mod get_channel_information {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = modify_channel_information::ModifyChannelInformationRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -371,7 +371,7 @@ pub mod modify_channel_information {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = start_commercial::StartCommercialRequest::new();
/// let body = start_commercial::StartCommercialBody::builder()
/// .broadcaster_id("1234".to_string())
Expand Down
4 changes: 2 additions & 2 deletions src/helix/clips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = GetClipsRequest::builder()
Expand Down Expand Up @@ -53,7 +53,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_clips::GetClipsRequest::builder()
/// .broadcaster_id("1234".to_string())
/// .build();
Expand Down
4 changes: 2 additions & 2 deletions src/helix/games.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_games::GetGamesRequest::builder()
/// .id(vec!["4321".to_string()])
/// .build();
Expand Down Expand Up @@ -150,7 +150,7 @@ pub mod get_games {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_top_games::GetTopGamesRequest::builder()
/// .build();
/// let response: Vec<get_top_games::Game> = client.req_get(request, &token).await?.data;
Expand Down
2 changes: 1 addition & 1 deletion src/helix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
/// # use twitch_api2::helix::{HelixClient, channels};
/// # let token = Box::new(twitch_oauth2::UserToken::from_existing_unchecked(
/// # twitch_oauth2::AccessToken::new("totallyvalidtoken".to_string()), None,
/// # twitch_oauth2::ClientId::new("validclientid".to_string()), None, None));
/// # twitch_oauth2::ClientId::new("validclientid".to_string()), None, None, None));
/// let req = channels::GetChannelInformationRequest::builder().broadcaster_id("123456").build();
/// let client = HelixClient::new();
/// # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
Expand Down
10 changes: 5 additions & 5 deletions src/helix/moderation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_moderators::GetModeratorsRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -171,7 +171,7 @@ pub mod get_moderators {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_moderator_events::GetModeratorEventsRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -334,7 +334,7 @@ pub mod get_moderator_events {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_banned_users::GetBannedUsersRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -464,7 +464,7 @@ pub mod get_banned_users {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_banned_events::GetBannedEventsRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down Expand Up @@ -647,7 +647,7 @@ pub mod get_banned_events {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = check_automod_status::CheckAutoModStatusRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down
6 changes: 3 additions & 3 deletions src/helix/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = SearchCategoriesRequest::builder()
Expand Down Expand Up @@ -55,7 +55,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = search_categories::SearchCategoriesRequest::builder()
/// .query("hello")
/// .build();
Expand Down Expand Up @@ -172,7 +172,7 @@ pub mod search_categories {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = search_channels::SearchChannelsRequest::builder()
/// .query("hello")
/// .build();
Expand Down
6 changes: 3 additions & 3 deletions src/helix/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = GetStreamsRequest::builder()
Expand Down Expand Up @@ -81,7 +81,7 @@ impl StreamType {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_streams::GetStreamsRequest::builder()
/// .user_login(vec!["justintvfan".to_string()])
/// .build();
Expand Down Expand Up @@ -254,7 +254,7 @@ pub mod get_streams {
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_stream_tags::GetStreamTagsRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down
4 changes: 2 additions & 2 deletions src/helix/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
//! # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
//! let client = HelixClient::new();
//! # let _: &HelixClient<twitch_api2::DummyHttpClient> = &client;
//! let req = GetBroadcasterSubscriptionsRequest::builder()
Expand Down Expand Up @@ -54,7 +54,7 @@ use serde::{Deserialize, Serialize};
/// # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
/// # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None).await?;
/// # let token = twitch_oauth2::UserToken::from_existing(twitch_oauth2::dummy_http_client, token, None, None).await?;
/// let request = get_broadcaster_subscriptions::GetBroadcasterSubscriptionsRequest::builder()
/// .broadcaster_id("1234")
/// .build();
Expand Down
Loading