-
Notifications
You must be signed in to change notification settings - Fork 36
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
implementation of twitch_oauth2::client::Client
is not general enough
#236
Comments
This comment has been minimized.
This comment has been minimized.
scratch that, that's not the error... minimal repro: use twitch_api2::{twitch_oauth2::*, *};
async fn get_auth_token_request(client: &TwitchClient<'static, reqwest::Client>) -> Result<AppAccessToken, ()> {
let client_id = ClientId::new("aaa");
let client_secret = ClientSecret::new("aaaa");
let token =
AppAccessToken::get_app_access_token(client, client_id, client_secret, Scope::all())
.await
.unwrap();
Ok(token)
}
fn spawn_followers_poll() {
let client: TwitchClient<'static, reqwest::Client> = TwitchClient::new();
tokio::spawn({
// <---- here is the error
async move {
get_auth_token_request(&client).await.unwrap();
}
});
}
pub fn main() {
} gives
I'm not sure if this is a library issue, or if it's a rust bug. |
I'm not 100% sure what this issue is, but to fix it there is a workaround. Instead of giving the so AppAccessToken::get_app_access_token(&client.helix.clone_client(), ...) I'm going to expose the I need to do some minimization of this to see if this is the same as above mentioned issue or if it's something else. |
Thanks ! I tried to implement the given solution like this: async fn get_auth_token_request(config: &Config) -> Result<AppAccessToken, AppError> {
let client_id = ClientId::new(config.twitch.api.id.clone());
let client_secret = ClientSecret::new(config.twitch.api.secret.clone());
let client: TwitchClient<'static, reqwest::Client> = TwitchClient::new();
let token = AppAccessToken::get_app_access_token( // <------ error here
&client.helix.clone_client(),
client_id,
client_secret,
Scope::all(),
)
.await
.unwrap();
Ok(token)
} This brings the following issue:
Then I tried to replace the reqwest client with the twitch_oauth2 one, even if I'm not sure why I'm required too. async fn get_auth_token_request(config: &Config) -> Result<AppAccessToken, AppError> {
let client_id = ClientId::new(config.twitch.api.id.clone());
let client_secret = ClientSecret::new(config.twitch.api.secret.clone());
let client: TwitchClient<'static, dyn twitch_oauth2::client::Client> = TwitchClient::new(); // <----- error 1 here (I tried with and without dyn keyword)
let token = AppAccessToken::get_app_access_token(
&client.helix.clone_client(), // <----- error 2 here
client_id,
client_secret,
Scope::all(),
)
.await
.unwrap();
Ok(token)
}
|
Second way wont work. the error message after doing the workaround suggests that you dont have |
this just works™️ now |
I'm trying to use the client in a
tokio::spawn
context but I get the following error.Following the exemple, I can see that we must explicit some lifetimes but I don't really understand what should be done.
Can you provide some help please ?
The text was updated successfully, but these errors were encountered: