tsk-41: Starting work to add auth to the requests
Some checks failed
Rust Build / Check (pull_request) Failing after 28s
Rust Build / Rustfmt (pull_request) Failing after 32s
Rust Build / Test Suite (pull_request) Failing after 37s
Rust Build / Clippy (pull_request) Failing after 35s
Rust Build / build (pull_request) Failing after 39s
Some checks failed
Rust Build / Check (pull_request) Failing after 28s
Rust Build / Rustfmt (pull_request) Failing after 32s
Rust Build / Test Suite (pull_request) Failing after 37s
Rust Build / Clippy (pull_request) Failing after 35s
Rust Build / build (pull_request) Failing after 39s
This commit is contained in:
21
src/api.rs
21
src/api.rs
@@ -2,7 +2,16 @@ pub async fn fetch_next_queue_item(app: &crate::config::App) -> Result<reqwest::
|
||||
let client = reqwest::Client::new();
|
||||
let fetch_endpoint = String::from("api/v2/song/queue/next");
|
||||
let api_url = format!("{}/{fetch_endpoint}", app.uri);
|
||||
client.get(api_url).send().await
|
||||
let (key, header) = auth_header(app).await;
|
||||
println!("Header: {header:?}");
|
||||
client.get(api_url).header(key, header)
|
||||
.send().await
|
||||
}
|
||||
|
||||
pub async fn auth_header(app: &crate::config::App) -> (reqwest::header::HeaderName, reqwest::header::HeaderValue) {
|
||||
let bearer = format!("Bearer {}", app.token.token);
|
||||
let header_value = reqwest::header::HeaderValue::from_str(&bearer).unwrap();
|
||||
(reqwest::header::AUTHORIZATION, header_value)
|
||||
}
|
||||
|
||||
pub mod parsing {
|
||||
@@ -143,3 +152,13 @@ pub mod service_token {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod refresh_token {
|
||||
pub mod response {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<icarus_models::login_result::LoginResult>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user