From: Yeray Diaz Diaz Date: Mon, 16 Sep 2019 11:50:00 +0000 (+0100) Subject: Document digest auth (#348) X-Git-Tag: 0.7.3~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8155352d2028b7f74ccd53acdf5a8d74b84e6d15;p=thirdparty%2Fhttpx.git Document digest auth (#348) * Document authentication * Fix linting errors * Tweak wording * Update docs/quickstart.md Co-Authored-By: Florimond Manca --- diff --git a/README.md b/README.md index 067cacf1..fd2546e7 100644 --- 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 diff --git a/docs/quickstart.md b/docs/quickstart.md index 6262ee2c..784072df 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -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) + diff --git a/setup.cfg b/setup.cfg index 4a647525..a9fc1a8f 100644 --- 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 diff --git a/tests/requests_compat/test_api.py b/tests/requests_compat/test_api.py index 0aff992f..39ae7121 100644 --- a/tests/requests_compat/test_api.py +++ b/tests/requests_compat/test_api.py @@ -1,6 +1,5 @@ """Test compatibility with the Requests high-level API.""" import pytest - import requests