Skip to content

Commit 59f8aa2

Browse files
authored
Add netrc file search information to authentication documentation (#6876)
1 parent 5b4b64c commit 59f8aa2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/user/authentication.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ set with `headers=`.
4444
If credentials for the hostname are found, the request is sent with HTTP Basic
4545
Auth.
4646

47+
Requests will search for the netrc file at `~/.netrc`, `~/_netrc`, or at the path
48+
specified by the `NETRC` environment variable. `~` denotes the user's home
49+
directory, which is `$HOME` on Unix based systems and `%USERPROFILE%` on Windows.
50+
51+
Usage of netrc file can be disabled by setting `trust_env` to `False` in the
52+
Requests session::
53+
54+
>>> s = requests.Session()
55+
>>> s.trust_env = False
56+
>>> s.get('https://httpbin.org/basic-auth/user/pass')
4757

4858
Digest Authentication
4959
---------------------

docs/user/quickstart.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Note: Custom headers are given less precedence than more specific sources of inf
222222
are specified in ``.netrc``, which in turn will be overridden by the ``auth=``
223223
parameter. Requests will search for the netrc file at `~/.netrc`, `~/_netrc`,
224224
or at the path specified by the `NETRC` environment variable.
225+
Check details in :ref:`netrc authentication <authentication>`.
225226
* Authorization headers will be removed if you get redirected off-host.
226227
* Proxy-Authorization headers will be overridden by proxy credentials provided in the URL.
227228
* Content-Length headers will be overridden when we can determine the length of the content.

0 commit comments

Comments
 (0)