diff --git a/core/src/keymaster.rs b/core/src/keymaster.rs index a4e0c169..493f5348 100644 --- a/core/src/keymaster.rs +++ b/core/src/keymaster.rs @@ -13,9 +13,22 @@ pub struct Token { pub scope: Vec, } -pub fn get_token(session: &Session, client_id: &str, scopes: &str) -> Box> { +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_id, scopes); + 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(); diff --git a/src/lib.rs b/src/lib.rs index 753827c6..80dad1bc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ #[macro_use] extern crate log; #[macro_use] extern crate serde_json; -#[macro_use] extern crate serde_derive; extern crate base64; extern crate crypto;