File tree 4 files changed +42
-0
lines changed
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 65
65
- [ Making Requests] ( web/clients/requests.md )
66
66
- [ Calling a Web API] ( web/clients/apis.md )
67
67
- [ Downloads] ( web/clients/download.md )
68
+ - [ Web Authentication] ( web/clients/authentication.md )
Original file line number Diff line number Diff line change 39
39
| [ Make a partial download with HTTP range headers] [ ex-progress-with-range ] | [ ![ reqwest-badge]] [ reqwest ] | [ ![ cat-net-badge]] [ cat-net ] |
40
40
| [ POST a file to paste-rs] [ ex-file-post ] | [ ![ reqwest-badge]] [ reqwest ] | [ ![ cat-net-badge]] [ cat-net ] |
41
41
42
+ ## Web Authentication
43
+
44
+ | Recipe | Crates | Categories |
45
+ | --------| --------| ------------|
46
+ | [ Basic Authentication] [ ex-basic-authentication ] | [ ![ reqwest-badge]] [ reqwest ] | [ ![ cat-net-badge]] [ cat-net ] |
47
+
42
48
[ ex-extract-links-webpage ] : web/scraping.html#extract-all-links-from-a-webpage-html
43
49
[ ex-check-broken-links ] : web/scraping.html#check-a-webpage-for-broken-links
44
50
[ ex-extract-mediawiki-links ] : web/scraping.html#extract-all-unique-links-from-a-mediawiki-markup
64
70
[ ex-progress-with-range ] : web/clients/download.html#make-a-partial-download-with-http-range-headers
65
71
[ ex-file-post ] : web/clients/download.html#post-a-file-to-paste-rs
66
72
73
+ [ ex-basic-authentication ] : web/clients/authentication.html#basic-authentication
74
+
67
75
{{#include links.md}}
Original file line number Diff line number Diff line change
1
+ # Authentication
2
+
3
+ {{#include authentication/basic.md}}
4
+
5
+ {{#include ../../links.md}}
Original file line number Diff line number Diff line change
1
+ ## Basic Authentication
2
+
3
+ [ ![ reqwest-badge]] [ reqwest ] [ ![ cat-net-badge]] [ cat-net ]
4
+
5
+ Uses [ ` reqwest::RequestBuilder::basic_auth ` ] to perform a basic HTTP authentication.
6
+
7
+ ``` rust,edition2018,no_run
8
+ use reqwest::blocking::Client;
9
+ use reqwest::Error;
10
+
11
+ fn main() -> Result<(), Error> {
12
+ let client = Client::new();
13
+
14
+ let user_name = "testuser".to_string();
15
+ let password: Option<String> = None;
16
+
17
+ let response = client
18
+ .get("https://httpbin.org/")
19
+ .basic_auth(user_name, password)
20
+ .send();
21
+
22
+ println!("{:?}", response);
23
+
24
+ Ok(())
25
+ }
26
+ ```
27
+
28
+ [ `reqwest::RequestBuilder::basic_auth` ] : https://docs.rs/reqwest/*/reqwest/struct.RequestBuilder.html#method.basic_auth
You can’t perform that action at this time.
0 commit comments