]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Document digest auth (#348)
authorYeray Diaz Diaz <yeraydiazdiaz@fastmail.com>
Mon, 16 Sep 2019 11:50:00 +0000 (12:50 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Sep 2019 11:50:00 +0000 (12:50 +0100)
* Document authentication

* Fix linting errors

* Tweak wording

* Update docs/quickstart.md

Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
README.md
docs/quickstart.md
setup.cfg
tests/requests_compat/test_api.py

index 067cacf1bd9b2bc219648e89fddc085830769c02..fd2546e783d85b9c6cb2bead79fdd4f0ccc55508 100644 (file)
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ Plus all the standard features of `requests`...
 * Keep-Alive & Connection Pooling
 * Sessions with Cookie Persistence
 * Browser-style SSL Verification
-* Basic/Digest Authentication *(Digest is still TODO)*
+* Basic/Digest Authentication
 * Elegant Key/Value Cookies
 * Automatic Decompression
 * Automatic Content Decoding
index 6262ee2cf2c0de392fd63cd368dc5e8817160072..784072dfc7868033519558af0100a8e31c99dbcd 100644 (file)
@@ -379,3 +379,25 @@ value to be more or less strict:
 ```python
 >>> httpx.get('https://github.com/', timeout=0.001)
 ```
+
+## Authentication
+
+HTTPX supports Basic and Digest HTTP authentication.
+
+To provide Basic authentication credentials, pass a 2-tuple of
+plaintext `str` or `bytes` objects as the `auth` argument to the request
+functions:
+
+```python
+>>> httpx.get("https://example.com", auth=("my_user", "password123"))
+```
+
+To provide credentials for Digest authentication you'll need to instantiate
+a `DigestAuth` object with the plaintext username and password as arguments.
+This object can be then passed as the `auth` argument to the request methods
+as above:
+
+```python
+>>> auth = httpx.DigestAuth("my_user", "password123")
+>>> httpx.get("https://example.com", auth=auth)
+<Response [200 OK]>
index 4a6475250c0c883a02b421e1e88385a89e61133e..a9fc1a8fe773f08858af18ceacda6a3156ec5692 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -11,7 +11,7 @@ combine_as_imports = True
 force_grid_wrap = 0
 include_trailing_comma = True
 known_first_party = httpx,tests
-known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,rfc3986,setuptools,trustme,uvicorn
+known_third_party = brotli,certifi,chardet,cryptography,h11,h2,hstspreload,nox,pytest,requests,rfc3986,setuptools,trustme,uvicorn
 line_length = 88
 multi_line_output = 3
 
index 0aff992ffabf77fe42e64a942f323282554f2964..39ae7121f930bf6f2023906dabd22c684abbd636 100644 (file)
@@ -1,6 +1,5 @@
 """Test compatibility with the Requests high-level API."""
 import pytest
-
 import requests