3
P\8 @ sH d Z ddlmZmZ ddlmZmZ G dd deZG dd deZdS ) z
requests_toolbelt.auth.handler
==============================
This holds all of the implementation details of the Authentication Handler.
)AuthBase
HTTPBasicAuth)urlparse
urlunparsec @ sT e Zd ZdZdd Zdd Zdd Zdd Zed
d Z dd
Z
dd Zdd ZdS )AuthHandlera
The ``AuthHandler`` object takes a dictionary of domains paired with
authentication strategies and will use this to determine which credentials
to use when making a request. For example, you could do the following:
.. code-block:: python
from requests import HTTPDigestAuth
from requests_toolbelt.auth.handler import AuthHandler
import requests
auth = AuthHandler({
'https://api.github.com': ('sigmavirus24', 'fakepassword'),
'https://example.com': HTTPDigestAuth('username', 'password')
})
r = requests.get('https://api.github.com/user', auth=auth)
# =>