
    !<i                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZ ddlmZ ddl	m
Z
 d	 Zd
 Zd Z G d d          Z G d d          ZdS )    N)to_bytes)	to_native)add_params_to_qs)add_params_to_uri   )OAuth2Token)add_bearer_tokenc                     | j          d| j         }t          t          j        t          |d                              }d| |d<   |||fS )N:latin1zBasic Authorization)	client_idclient_secretr   base64	b64encoder   )clientmethoduriheadersbodytextauths          /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/authlib/oauth2/auth.pyencode_client_secret_basicr      sZ    77!577DV%htX&>&>??@@D.GO    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"      si    
&*+f28b9	
 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__=   sE    /K"*$3333K@K&r   c                 4    |                      | ||||          S N)r-   )r.   r   r   r   r   s        r   preparezClientAuth.prepareI   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                   8    e Zd ZdZdZdeiZd	dZ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__\   s2     *511
.UU


r   c                 8    t          j        |          | _        d S r1   )r   r=   r>   )r.   r>   s     r   	set_tokenzTokenAuth.set_tokenb   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.preparee   s    Z^^L$2IJJ
 !1!1!3!34!TJ~&WdD<P
 
Wd J 	: 	:D!%c7D!9!9C$$GT!!r   c                     | ` | `d S r1   )r   rA   )r.   s    r   __del__zTokenAuth.__del__q   s    KJJJr   )r;   N)r3   r4   r5   r6   rH   r	   rI   r/   rC   r2   rN   r7   r   r   r9   r9   M   sr        	 	 "./L   2 2 2
" 
" 
"    r   r9   )r   authlib.common.encodingr   r   authlib.common.urlsr   r   rfc6749r   rfc6750r	   r   r"   r%   r'   r9   r7   r   r   <module>rS      s
    , , , , , , - - - - - - 0 0 0 0 0 0 1 1 1 1 1 1             % % % % % %  
 
 
   B  B  B  B  B  B  B  BF& & & & & & & & & &r   