| Server IP : 46.245.81.90 / Your IP : 216.73.216.85 Web Server : Apache System : Linux server3ir.xdlhost.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64 User : gmparts ( 1037) PHP Version : 8.1.34 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3.6/site-packages/requests_toolbelt/auth/__pycache__/ |
Upload File : |
3
�P\8 � @ sH d Z ddlmZmZ ddlmZmZ G dd� de�ZG dd� de�ZdS ) 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)
# => <Response [200]>
r = requests.get('https://example.com/some/path', auth=auth)
# => <Response [200]>
s = requests.Session()
s.auth = auth
r = s.get('https://api.github.com/user')
# => <Response [200]>
.. warning::
:class:`requests.auth.HTTPDigestAuth` is not yet thread-safe. If you
use :class:`AuthHandler` across multiple threads you should
instantiate a new AuthHandler for each thread with a new
HTTPDigestAuth instance for each thread.
c C s t |�| _| j� d S )N)�dict�
strategies�
_make_uniform)�selfr � r �/usr/lib/python3.6/handler.py�__init__6 s
zAuthHandler.__init__c C s | j |j�}||�S )N)�get_strategy_for�url)r
ZrequestZauthr r r �__call__: s zAuthHandler.__call__c C s dj | j�S )Nz<AuthHandler({0!r})>)�formatr )r
r r r �__repr__>