mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
Remove keymaster
and update example
This commit is contained in:
parent
3a7843d049
commit
d3074f597a
3 changed files with 3 additions and 33 deletions
|
@ -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)
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue