
    k7i                         S SK r S SKJr  S SKJr  S SKJr  S SKJr  SSKJr  SSK	J
r
  S	 rS
 rS r " S S5      r " S S5      rg)    N)to_bytes)	to_native)add_params_to_qs)add_params_to_uri   )OAuth2Token)add_bearer_tokenc                     U R                    SU R                   3n[        [        R                  " [        US5      5      5      nSU 3US'   X#U4$ )N:latin1zBasic Authorization)	client_idclient_secretr   base64	b64encoder   )clientmethoduriheadersbodytextauths          M/home/james-whalen/.local/lib/python3.13/site-packages/authlib/oauth2/auth.pyencode_client_secret_basicr      sW    q!5!5 67DV%%htX&>?@D!'vGO    c                     [        U=(       d    SSU R                  4SU R                  =(       d    S4/5      nSU;   a  [        [	        U5      5      US'   X#U4$ )N r   r   Content-Length)r   r   r   strlenr   r   r   r   r   s        r   encode_client_secret_postr"      sa    
&**+f228b9	
D 7"$'D	N !r   c                     US:X  a  [        USU R                  4/5      nX#U4$ [        USU R                  4/5      nSU;   a  [        [	        U5      5      US'   X#U4$ )NGETr   r   )r   r   r   r   r    r!   s        r   encode_noner%       sn    {F4D4D&E%FGT!!DK1A1A#B"CDD7"$'D	N !r   c                   4    \ rS rSrSr\\\S.rSS jr	S r
Srg)	
ClientAuth*   ag  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                 n    Uc  SnXl         X l        X0R                  ;   a  U R                  U   nX0l        g )Nr)   )r   r   DEFAULT_AUTH_METHODSauth_method)selfr   r   r.   s       r   __init__ClientAuth.__init__=   s:    /K"*33333K@K&r   c                 (    U R                  XX#U5      $ N)r.   )r/   r   r   r   r   s        r   prepareClientAuth.prepareI   s    cDAAr   )r.   r   r   r3   )__name__
__module____qualname____firstlineno____doc__r   r"   r%   r-   r0   r4   __static_attributes__ r   r   r'   r'   *   s%    
  :7
'Br   r'   c                   @    \ rS rSrSrSrS\0rS
S jrS r	S r
S rS	rg)	TokenAuthM   zAttach 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
bearerNc                 p    [         R                  " U5      U l        X l        X0l        [        5       U l        g r3   )r   	from_dicttokentoken_placementr   sethooks)r/   rC   rD   r   s       r   r0   TokenAuth.__init__\   s(     **51
.U
r   c                 :    [         R                  " U5      U l        g r3   )r   rB   rC   )r/   rC   s     r   	set_tokenTokenAuth.set_tokenb   s     **51
r   c                    U R                   R                  SU R                  5      nU R                  UR	                  5          nU" U R                   S   XX0R
                  5      u  pnU R                   H  nU" XU5      u  pnM     XU4$ )N
token_typeaccess_token)rC   getDEFAULT_TOKEN_TYPESIGN_METHODSlowerrD   rF   )r/   r   r   r   rL   signhooks          r   r4   TokenAuth.preparee   s    ZZ^^L$2I2IJ
  !1!1!34!JJ~&d<P<P
d JJD!%cD!9C$  T!!r   c                     U ? U ?g r3   )r   rF   )r/   s    r   __del__TokenAuth.__del__q   s    KJr   )r   rF   rC   rD   )headerN)r6   r7   r8   r9   r:   rO   r	   rP   r0   rI   r4   rV   r;   r<   r   r   r>   r>   M   s.    	 "./L2
"r   r>   )r   authlib.common.encodingr   r   authlib.common.urlsr   r   rfc6749r   rfc6750r	   r   r"   r%   r'   r>   r<   r   r   <module>r]      s@     , - 0 1   %
 B  BF& &r   