Skip to content

Commit

Permalink
Merge pull request #6018 from nateprewitt/basic_auth_update
Browse files Browse the repository at this point in the history
Update basic auth example
  • Loading branch information
sigmavirus24 committed Dec 29, 2021
2 parents 39d0fdd + 401e17b commit e2064a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/user/authentication.rst
Expand Up @@ -19,13 +19,14 @@ the simplest kind, and Requests supports it straight out of the box.
Making requests with HTTP Basic Auth is very simple::

>>> from requests.auth import HTTPBasicAuth
>>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass'))
>>> basic = HTTPBasicAuth('user', 'pass')
>>> requests.get('https://httpbin.org/basic-auth/user/pass', auth=basic)
<Response [200]>

In fact, HTTP Basic Auth is so common that Requests provides a handy shorthand
for using it::

>>> requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass'))
<Response [200]>

Providing the credentials in a tuple like this is exactly the same as the
Expand Down

0 comments on commit e2064a2

Please sign in to comment.