Skip to content
Myr

Merge pull request #6018 from nateprewitt/basic_auth_update

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

Update basic auth example

authored by Ian Stapleton Cordasco · committed by GitHub · parents 39d0fdd, 401e17b · Browse files · 1 file+3 added−2 removed
This commit

State

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

Diff stats

1 file+3 added−2 removed

  • other:+3 added−2 removed

1 file+3 added−2 removed

modified:docs/user/authentication.rst+3 added-2 removed
17 unmodified lines
1819Making requests with HTTP Basic Auth is very simple::2021 >>> from requests.auth import HTTPBasicAuth22 >>> requests.get('https://api.github.com/user', auth=HTTPBasicAuth('user', 'pass'))22 >>> basic = HTTPBasicAuth('user', 'pass')23 >>> requests.get('https://httpbin.org/basic-auth/user/pass', auth=basic)24 <Response [200]>2526In fact, HTTP Basic Auth is so common that Requests provides a handy shorthand27for using it::2828 >>> requests.get('https://api.github.com/user', auth=('user', 'pass'))29 >>> requests.get('https://httpbin.org/basic-auth/user/pass', auth=('user', 'pass'))30 <Response [200]>3132Providing the credentials in a tuple like this is exactly the same as the33``HTTPBasicAuth`` example above.
112 unmodified lines