diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/playlists/main.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/playlists/main.rs b/examples/playlists/main.rs index fed5b73..81d3cf2 100644 --- a/examples/playlists/main.rs +++ b/examples/playlists/main.rs @@ -2,7 +2,7 @@ use std::error::Error; use anyhow::Context; use config::Config; -use deez::auth::{request_access_token, AuthPromptHandler}; +use deez::auth::AuthPromptHandler; use deez::client::DeezerClient; use serde::Deserialize; @@ -40,8 +40,11 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> println!("Retrieved authentication code '{}'", auth_code); - let access_token = - request_access_token(settings.app_id, settings.secret_key, auth_code).await?; + let client = DeezerClient::new(); + + let access_token = client + .get_access_token(settings.app_id, settings.secret_key, auth_code) + .await?; println!( "Retrieved access token '{}' which expires in {} seconds", @@ -49,13 +52,11 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> access_token.expires.as_secs() ); - let client = DeezerClient::new(access_token); - - let me = client.get_me().await?; + let me = client.get_me(access_token.clone()).await?; println!("{:#?}", me); - let playlists = client.get_user_playlists(me.id).await?; + let playlists = client.get_user_playlists(me.id, access_token).await?; println!("Playlists: {:#?}", playlists); |