Web Authentication - Rust Cookbook (original) (raw)
- Table of Contents
- About
- 1. Algorithms
- 2. Command Line
- 3. Compression
- 4. Concurrency
- 4.2. Data Parallelism
- 5. Cryptography
- 5.2. Encryption
- 6. Data Structures
- 7. Database
- 7.2. Postgres
- 8. Date and Time
- 8.2. Parsing and Displaying
- 9. Development Tools
- 9.2. Versioning
- 9.3. Build Time Tooling
- 10. Encoding
- 10.2. CSV processing
- 10.3. Structured Data
- 11. Error Handling
- 12. File System
- 12.2. Directory Traversal
- 13. Hardware Support
- 14. Memory Management
- 15. Network
- 16. Operating System
- 17. Science
- 18. Text Processing
- 18.2. String Parsing
- 19. Web Programming
- 19.2. URL
- 19.3. Media Types
- 19.4. Clients
Rust Cookbook
Authentication
Basic Authentication
Uses reqwest::RequestBuilder::basic_auth to perform a basic HTTP authentication.
use reqwest::blocking::Client;
use reqwest::Error;
fn main() -> Result<(), Error> {
let client = Client::new();
let user_name = "testuser".to_string();
let password: Option<String> = None;
let response = client
.get("https://httpbin.org/")
.basic_auth(user_name, password)
.send();
println!("{:?}", response);
Ok(())
}