diff --git a/core/src/keymaster.rs b/core/src/keymaster.rs index 493f5348..5a8fa3b3 100644 --- a/core/src/keymaster.rs +++ b/core/src/keymaster.rs @@ -14,21 +14,8 @@ pub struct Token { } pub fn get_token(session: &Session, client_id: Option<&str>, scopes: &str) -> Box> { - let client_id_env: Option<&'static str> = option_env!("CLIENT_ID"); - let client_key: &str; - - 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); + let client_key = option_env!("CLIENT_ID").or(client_id).expect("No Client ID available"); + let url = format!("hm://keymaster/token/authenticated?client_id={}&scope={}", client_key, scopes); Box::new(session.mercury().get(url).map(move |response| { let data = response.payload.first().expect("Empty payload"); let data = String::from_utf8(data.clone()).unwrap();