
    Ld                         d dl Z d dlmZmZ d dlmZmZ ddlmZ ddl	m
Z
 d Zd Zd	 Z G d
 de          Z G d de          ZdS )    N)add_params_to_qsadd_params_to_uri)to_bytes	to_native   )OAuth2Token)add_bearer_tokenc                     d                     | j        | j                  }t          t	          j        t          |d                              }d                     |          |d<   |||fS )Nz{}:{}latin1zBasic {}Authorization)format	client_idclient_secretr   base64	b64encoder   )clientmethoduriheadersbodytextauths          9F:\djangOuth\env\Lib\site-packages\authlib/oauth2/auth.pyencode_client_secret_basicr      sb    >>&*F,@AADV%htX&>&>??@@D)0066GO    c                     t          |pdd| j        fd| j        pdfg          }d|v rt          t	          |                    |d<   |||fS )N r   r   Content-Length)r   r   r   strlenr   r   r   r   r   s        r   encode_client_secret_postr"      sh    DJB	f&'	&.4"5)  D 7""$'D		NN !r   c                     |dk    rt          |d| j        fg          }|||fS t          |d| j        fg          }d|v rt          t	          |                    |d<   |||fS )NGETr   r   )r   r   r   r   r    r!   s        r   encode_noner%      s{    {F4D&E%FGGGT!!DK1A#B"CDDD7""$'D		NN !r   c                   ,    e Zd ZdZeeedZddZd Z	dS )
ClientAutha  Attaches OAuth Client Information to HTTP requests.

    :param client_id: Client ID, which you get from client registration.
    :param client_secret: Client Secret, which you get from registration.
    :param auth_method: Client auth method for token endpoint. The supported
        methods for now:

        * client_secret_basic (default)
        * client_secret_post
        * none
    )client_secret_basicclient_secret_postnoneNc                 d    |d}|| _         || _        || j        v r| j        |         }|| _        d S )Nr(   )r   r   DEFAULT_AUTH_METHODSauth_method)selfr   r   r-   s       r   __init__zClientAuth.__init__5   sE    /K"*$3333K@K&r   c                 4    |                      | ||||          S N)r-   )r.   r   r   r   r   s        r   preparezClientAuth.prepareA   s    fc7DAAAr   r1   )
__name__
__module____qualname____doc__r   r"   r%   r,   r/   r2    r   r   r'   r'   #   s^        
 
  :7 
' 
' 
' 
'B B B B Br   r'   c                   2    e Zd ZdZdZdeiZddZd Zd Z	dS )		TokenAutha  Attach token information to HTTP requests.

    :param token: A dict or OAuth2Token instance of an OAuth 2.0 token
    :param token_placement: The placement of the token, default is ``header``,
        available choices:

        * header (default)
        * body
        * uri
    bearerheaderNc                 z    t          j        |          | _        || _        || _        t                      | _        d S r1   )r   	from_dicttokentoken_placementr   sethooks)r.   r>   r?   r   s       r   r/   zTokenAuth.__init__U   s2     *511
.UU


r   c                 8    t          j        |          | _        d S r1   )r   r=   r>   )r.   r>   s     r   	set_tokenzTokenAuth.set_token[   s     *511


r   c                    | j                             d| j                  }| j        |                                         } || j         d         |||| j                  \  }}}| j        D ]} ||||          \  }}}|||fS )N
token_typeaccess_token)r>   getDEFAULT_TOKEN_TYPESIGN_METHODSlowerr?   rA   )r.   r   r   r   rE   signhooks          r   r2   zTokenAuth.prepare^   s    Z^^L$2IJJ
 !1!1!3!34!TJ~&$ " "Wd
 J 	: 	:D!%c7D!9!9C$$GT!!r   )r;   N)
r3   r4   r5   r6   rH   r	   rI   r/   rC   r2   r7   r   r   r9   r9   E   se        	 	 ""L   2 2 2" " " " "r   r9   )r   authlib.common.urlsr   r   authlib.common.encodingr   r   rfc6749r   rfc6750r	   r   r"   r%   objectr'   r9   r7   r   r   <module>rR      s     C C C C C C C C 7 7 7 7 7 7 7 7             % % % % % %      B B B B B B B BD$" $" $" $" $" $" $" $" $" $"r   