mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Code Tidyup
This commit is contained in:
parent
9784d98847
commit
4205f9c18b
1 changed files with 2 additions and 15 deletions
|
@ -14,21 +14,8 @@ pub struct Token {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_token(session: &Session, client_id: Option<&str>, scopes: &str) -> Box<Future<Item = Token, Error = MercuryError>> {
|
pub fn get_token(session: &Session, client_id: Option<&str>, scopes: &str) -> Box<Future<Item = Token, Error = MercuryError>> {
|
||||||
let client_id_env: Option<&'static str> = option_env!("CLIENT_ID");
|
let client_key = option_env!("CLIENT_ID").or(client_id).expect("No Client ID available");
|
||||||
let client_key: &str;
|
let url = format!("hm://keymaster/token/authenticated?client_id={}&scope={}", client_key, scopes);
|
||||||
|
|
||||||
match client_id_env {
|
|
||||||
None => {
|
|
||||||
match client_id {
|
|
||||||
None => { panic!("No Client ID available.") },
|
|
||||||
Some(ref cid) => { client_key = cid },
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Some(ref cid_env) => { client_key = cid_env }
|
|
||||||
}
|
|
||||||
|
|
||||||
let url = format!("hm://keymaster/token/authenticated?client_id={}&scope={}",
|
|
||||||
client_key, scopes);
|
|
||||||
Box::new(session.mercury().get(url).map(move |response| {
|
Box::new(session.mercury().get(url).map(move |response| {
|
||||||
let data = response.payload.first().expect("Empty payload");
|
let data = response.payload.first().expect("Empty payload");
|
||||||
let data = String::from_utf8(data.clone()).unwrap();
|
let data = String::from_utf8(data.clone()).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue