Skip to content
Myr

Docs: clarify the precedence of `auth=` over `netrc`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This closes #2062 by clarifying in the docs which auth header takes precedence: 1st auth= 2nd .netrc 3rd headers= This precedence order is already tested in test_requests.py, in the test_basicauth_with_netrc method. Perhaps we should add further tests for non-basic auth schemes.

authored by Isa Hassen · committed by Isa Hassen · parent 728c318 · Browse files · 2 files+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−3 removed

  • other:+5 added−3 removed

2 files+5 added−3 removed

modified:docs/user/authentication.rst+2 added-2 removed
35 unmodified lines
36~~~~~~~~~~~~~~~~~~~~3738If no authentication method is given with the ``auth`` argument, Requests will39attempt to get the authentication credentials for the URL's hostname from the40user's netrc file.40user's netrc file. The netrc file overrides raw HTTP authentication headers41set with `headers=`.4243If credentials for the hostname are found, the request is sent with HTTP Basic44Auth.45
79 unmodified lines
125.. _requests_oauthlib: https://github.com/requests/requests-oauthlib126.. _Kerberos: https://github.com/requests/requests-kerberos127.. _NTLM: https://github.com/requests/requests-ntlm128.. _Requests organization: https://github.com/requests128
modified:docs/user/quickstart.rst+3 added-1 removed
195 unmodified lines
196 >>> r = requests.get(url, headers=headers)197198Note: Custom headers are given less precedence than more specific sources of information. For instance:199200* Authorization headers will be overridden if credentials are passed via the ``auth`` parameter or are specified in a ``.netrc`` accessible in the environment.200* Authorization headers set with `headers=` will be overridden if credentials201are specified in ``.netrc``, which in turn will be overridden by the ``auth=``202parameter.203* Authorization headers will be removed if you get redirected off-host.204* Proxy-Authorization headers will be overridden by proxy credentials provided in the URL.205* Content-Length headers will be overridden when we can determine the length of the content.206
289 unmodified lines