Remove keymaster and update example

This commit is contained in:
Roderick van Domburg 2021-06-22 21:49:36 +02:00
parent 3a7843d049
commit d3074f597a
No known key found for this signature in database
GPG key ID: 7076AA781B43EFE6
3 changed files with 3 additions and 33 deletions

View file

@ -1,26 +0,0 @@
use serde::Deserialize;
use crate::{mercury::MercuryError, session::Session};
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Token {
pub access_token: String,
pub expires_in: u32,
pub token_type: String,
pub scope: Vec<String>,
}
pub async fn get_token(
session: &Session,
client_id: &str,
scopes: &str,
) -> Result<Token, MercuryError> {
let url = format!(
"hm://keymaster/token/authenticated?client_id={}&scope={}",
client_id, scopes
);
let response = session.mercury().get(url).await?;
let data = response.payload.first().expect("Empty payload");
serde_json::from_slice(data.as_ref()).map_err(|_| MercuryError)
}

View file

@ -20,7 +20,6 @@ mod dealer;
#[doc(hidden)]
pub mod diffie_hellman;
mod http_client;
pub mod keymaster;
pub mod mercury;
mod proxytunnel;
pub mod session;

View file

@ -2,7 +2,6 @@ use std::env;
use librespot::core::authentication::Credentials;
use librespot::core::config::SessionConfig;
use librespot::core::keymaster;
use librespot::core::session::Session;
const SCOPES: &str =
@ -13,8 +12,8 @@ async fn main() {
let session_config = SessionConfig::default();
let args: Vec<_> = env::args().collect();
if args.len() != 4 {
eprintln!("Usage: {} USERNAME PASSWORD CLIENT_ID", args[0]);
if args.len() != 3 {
eprintln!("Usage: {} USERNAME PASSWORD", args[0]);
return;
}
@ -26,8 +25,6 @@ async fn main() {
println!(
"Token: {:#?}",
keymaster::get_token(&session, &args[3], SCOPES)
.await
.unwrap()
session.token_provider().get_token(SCOPES).await.unwrap()
);
}