There's more...

Adding the user and password to the URL works on the browser as well. Try to access the page directly to see a box displayed asking for the username and password:

User credentials page

When using the URL containing the user and password, https://user:[email protected]/basic-auth/user/psswd, the dialog does not appear and it authenticates automatically.

If you need to access multiple pages, you can create a session in requests and set the authentication parameters to avoid having to input them everywhere:

>>> s = requests.Session()
>>> s.auth = ('user', 'psswd')
>>> s.get('https://httpbin.org/basic-auth/user/psswd')
<Response [200]>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.162.233