Skip to content

Commit

Permalink
add: basic_auth.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
raghav-rama committed Feb 25, 2024
1 parent 943e6e4 commit acb772f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/bin/basic_auth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use error_chain::error_chain;
use reqwest::blocking::Client;

error_chain! {
foreign_links {
Io(std::io::Error);
HttpError(reqwest::Error);
}
}

fn main() -> Result<()> {
let client = Client::new();
let user = String::from("testuser");
let passwd = Option::<String>::None;
let url = format!("https://httpbin.org/get");
let response = client.get(&url).basic_auth(user, passwd).send()?;
println!("{:?}", response);
Ok(())
}

0 comments on commit acb772f

Please sign in to comment.