Use Authorization Header instead of Bearer Auth Header
All checks were successful
Run Tests on Code / run-tests (push) Successful in 20s
All checks were successful
Run Tests on Code / run-tests (push) Successful in 20s
This commit is contained in:
parent
a9245c1a3c
commit
838414f9d6
1 changed files with 6 additions and 6 deletions
12
src/main.rs
12
src/main.rs
|
@ -199,7 +199,7 @@ async fn upload_file(state: &mut App, request: Request) {
|
|||
///$KAVITA_URL/api/Library/scan-folder
|
||||
let client = reqwest::Client::new();
|
||||
let jwt_url = format!("{}/api/Plugin/authenticate?apiKey={}&pluginName=kwm-api", var("KAVITA_URL").expect("KAVITA_URL needs to be set in the .env file"), var("KAVITA_API_KEY").expect("KAVITA_API_KEY needs to be set in the .env file"));
|
||||
|
||||
|
||||
match client.post(jwt_url).send().await {
|
||||
Ok(data) => {
|
||||
let auth: PluginAuthResponse = serde_json::from_str(&data.text().await.unwrap()).unwrap();
|
||||
|
@ -214,7 +214,7 @@ async fn upload_file(state: &mut App, request: Request) {
|
|||
|
||||
let res = client
|
||||
.post(url)
|
||||
.bearer_auth(auth.token)
|
||||
.header(reqwest::header::AUTHORIZATION, auth.token)
|
||||
.body(body)
|
||||
.send()
|
||||
.await;
|
||||
|
@ -229,12 +229,12 @@ async fn upload_file(state: &mut App, request: Request) {
|
|||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
async fn stream_to_file(path: &PathBuf, stream: BodyDataStream) -> Result<(), (StatusCode, String)>
|
||||
|
|
Loading…
Reference in a new issue