Skip to content

Commit 8155352

Browse files
Document digest auth (#348)
* Document authentication * Fix linting errors * Tweak wording * Update docs/quickstart.md Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
1 parent 6c6148e commit 8155352

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Plus all the standard features of `requests`...
5656
* Keep-Alive & Connection Pooling
5757
* Sessions with Cookie Persistence
5858
* Browser-style SSL Verification
59-
* Basic/Digest Authentication *(Digest is still TODO)*
59+
* Basic/Digest Authentication
6060
* Elegant Key/Value Cookies
6161
* Automatic Decompression
6262
* Automatic Content Decoding

docs/quickstart.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,25 @@ value to be more or less strict:
379379
```python
380380
>>> httpx.get('https://github.com/', timeout=0.001)
381381
```
382+
383+
## Authentication
384+
385+
HTTPX supports Basic and Digest HTTP authentication.
386+
387+
To provide Basic authentication credentials, pass a 2-tuple of
388+
plaintext `str` or `bytes` objects as the `auth` argument to the request
389+
functions:
390+
391+
```python
392+
>>> httpx.get("https://example.com", auth=("my_user", "password123"))
393+
```
394+
395+
To provide credentials for Digest authentication you'll need to instantiate
396+
a `DigestAuth` object with the plaintext username and password as arguments.
397+
This object can be then passed as the `auth` argument to the request methods
398+
as above:
399+
400+
```python
401+
>>> auth = httpx.DigestAuth("my_user", "password123")
402+
>>> httpx.get("https://example.com", auth=auth)
403+
<Response [200 OK]>

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ combine_as_imports = True
1111
force_grid_wrap = 0
1212
include_trailing_comma = True
1313
known_first_party = httpx,tests
14-
known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,rfc3986,setuptools,trustme,uvicorn
14+
known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,requests,rfc3986,setuptools,trustme,uvicorn
1515
line_length = 88
1616
multi_line_output = 3
1717

tests/requests_compat/test_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Test compatibility with the Requests high-level API."""
22
import pytest
3-
43
import requests
54

65

0 commit comments

Comments
 (0)