2020-08-25 21:13:46 +00:00
|
|
|
use std::env;
|
|
|
|
|
2022-01-16 00:29:50 +00:00
|
|
|
use librespot::core::{authentication::Credentials, config::SessionConfig, session::Session};
|
2020-08-25 21:13:46 +00:00
|
|
|
|
|
|
|
const SCOPES: &str =
|
|
|
|
"streaming,user-read-playback-state,user-modify-playback-state,user-read-currently-playing";
|
|
|
|
|
2021-03-06 00:29:08 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
2020-08-25 21:13:46 +00:00
|
|
|
let session_config = SessionConfig::default();
|
|
|
|
|
|
|
|
let args: Vec<_> = env::args().collect();
|
2021-06-22 19:49:36 +00:00
|
|
|
if args.len() != 3 {
|
|
|
|
eprintln!("Usage: {} USERNAME PASSWORD", args[0]);
|
2021-03-06 00:29:08 +00:00
|
|
|
return;
|
2020-08-25 21:13:46 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 00:29:50 +00:00
|
|
|
println!("Connecting...");
|
2021-03-06 00:29:08 +00:00
|
|
|
let credentials = Credentials::with_password(&args[1], &args[2]);
|
2022-01-16 00:29:50 +00:00
|
|
|
let session = Session::new(session_config, None);
|
2020-08-25 21:13:46 +00:00
|
|
|
|
2022-07-27 21:31:11 +00:00
|
|
|
match session.connect(credentials, false).await {
|
2022-01-16 00:29:50 +00:00
|
|
|
Ok(()) => println!(
|
|
|
|
"Token: {:#?}",
|
|
|
|
session.token_provider().get_token(SCOPES).await.unwrap()
|
|
|
|
),
|
|
|
|
Err(e) => println!("Error connecting: {}", e),
|
|
|
|
}
|
2020-08-25 21:13:46 +00:00
|
|
|
}
|