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

This commit is contained in:
2025-08-13 17:55:30 -04:00
parent 62a1f8a003
commit b5f7943938
2 changed files with 59 additions and 11 deletions

View File

@@ -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>,
}
}
}