U
    6d                     @   sH   d dl mZ d dlmZmZ d dlmZ d dlmZ G dd deZdS )    )unicode_literals)WebApplicationClientInsecureTransportError)is_secure_transport)AuthBasec                   @   s"   e Zd ZdZdddZdd ZdS )OAuth2z:Adds proof of authorization (OAuth2 token) to the request.Nc                 C   s:   |pt ||d| _|r6| D ]\}}t| j|| qdS )a  Construct a new OAuth 2 authorization object.

        :param client_id: Client id obtained during registration
        :param client: :class:`oauthlib.oauth2.Client` to be used. Default is
                       WebApplicationClient which is useful for any
                       hosted application but not mobile or desktop.
        :param token: Token dictionary, must include access_token
                      and token_type.
        )tokenN)r   _clientitemssetattr)selfZ	client_idclientr   kv r   A/tmp/pip-unpacked-wheel-h5x5xq8v/requests_oauthlib/oauth2_auth.py__init__
   s    
zOAuth2.__init__c                 C   s<   t |jst | jj|j|j|j|jd\|_|_|_|S )a  Append an OAuth 2 token to the request.

        Note that currently HTTPS is required for all requests. There may be
        a token type that allows for plain HTTP in the future and then this
        should be updated to allow plain HTTP on a white list basis.
        )Zhttp_methodbodyheaders)r   urlr   r	   Z	add_tokenmethodr   r   )r   rr   r   r   __call__   s    
   zOAuth2.__call__)NNN)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s   
r   N)	
__future__r   Zoauthlib.oauth2r   r   r   Zrequests.authr   r   r   r   r   r   <module>   s   