mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: 🛂 properly handle missing api token entry
This commit is contained in:
parent
60760d07c4
commit
7cb08e7dcd
1 changed files with 13 additions and 4 deletions
17
src/main.rs
17
src/main.rs
|
@ -1,3 +1,4 @@
|
|||
use anyhow::bail;
|
||||
use std::{
|
||||
fs::{create_dir_all, read},
|
||||
hash::{DefaultHasher, Hash, Hasher},
|
||||
|
@ -184,12 +185,20 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let mut header_map = reqwest::header::HeaderMap::new();
|
||||
header_map.insert(ACCEPT, "application/json".parse()?);
|
||||
header_map.insert(
|
||||
AUTHORIZATION,
|
||||
format!("Bearer {}", api_token_entry.get_password()?).parse()?,
|
||||
);
|
||||
header_map.insert("X-GitHub-Api-Version", "2022-11-28".parse()?);
|
||||
|
||||
match api_token_entry.get_password() {
|
||||
Ok(api_token) => {
|
||||
header_map.insert(AUTHORIZATION, format!("Bearer {api_token}").parse()?);
|
||||
}
|
||||
Err(err) => match err {
|
||||
keyring::Error::NoEntry => {}
|
||||
_ => {
|
||||
bail!("error getting api token from keyring: {err}")
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let reqwest_client = reqwest::blocking::Client::builder()
|
||||
.user_agent(concat!(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
|
|
Loading…
Reference in a new issue