
    k7is                         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SK	Jr  SS	K	Jr  SS
K	Jr  SSKJr  SS/r " S S\\5      r " S S\\5      r " S S\\5      rg)    )Session)AuthBase)
ClientAuth)	TokenAuth)OAuth2Client   )InvalidTokenError)MissingTokenError)
OAuthError)UnsupportedTokenTypeError   )update_session_configureOAuth2Session
OAuth2Authc                   $    \ rS rSrSrS rS rSrg)r      zFSign requests for OAuth 2.0, currently only bearer token is supported.c                     U R                   (       a5  U R                   R                  U R                  5      (       d
  [        5       eg g N)clientensure_active_tokentokenr	   )selfs    m/home/james-whalen/.local/lib/python3.13/site-packages/authlib/integrations/requests_client/oauth2_session.pyr   OAuth2Auth.ensure_active_token   s2    ;;t{{>>tzzJJ#%%  K;    c                    U R                  5          U R                  UR                  UR                  UR                  5      u  Ul        Ul        Ul        U$ ! [
         a  nS[        U5       3n[        US9UeS nAff = f)NzUnsupported token_type: )description)r   prepareurlheadersbodyKeyErrorstrr   )r   reqerrorr   s       r   __call__OAuth2Auth.__call__   sz      "	P-1\\chh.*CGS[#( 
  	P4SZLAK+D%O	Ps   AA 
A?"A::A? N)__name__
__module____qualname____firstlineno____doc__r   r&   __static_attributes__r(   r   r   r   r      s    P&	r   c                       \ rS rSrSrS rSrg)OAuth2ClientAuth$   zAAttaches OAuth Client Authentication to the given Request object.c                     U R                  UR                  UR                  UR                  UR                  5      u  Ul        Ul        Ul        U$ r   )r   methodr   r    r!   )r   r$   s     r   r&   OAuth2ClientAuth.__call__'   s=    )-JJchh*
&ch 
r   r(   N)r)   r*   r+   r,   r-   r&   r.   r(   r   r   r0   r0   $   s
    Kr   r0   c                   l   ^  \ rS rSrSr\r\r\	r
Sr            SS jrS	S jrS
U 4S jjrSrU =r$ )r   .   ag  Construct a new OAuth 2 client requests session.

:param client_id: Client ID, which you get from client registration.
:param client_secret: Client Secret, which you get from registration.
:param authorization_endpoint: URL of the authorization server's
    authorization endpoint.
:param token_endpoint: URL of the authorization server's token endpoint.
:param token_endpoint_auth_method: client authentication method for
    token endpoint.
:param revocation_endpoint: URL of the authorization server's OAuth 2.0
    revocation endpoint.
:param revocation_endpoint_auth_method: client authentication method for
    revocation endpoint.
:param scope: Scope that you needed to access user resources.
:param state: Shared secret to prevent CSRF attack.
:param redirect_uri: Redirect URI you registered as callback.
:param token: A dict of token attributes such as ``access_token``,
    ``token_type`` and ``expires_at``.
:param token_placement: The place to put token in HTTP request. Available
    values: "header", "body", "uri".
:param update_token: A function for you to update token. It accept a
    :class:`OAuth2Token` as parameter.
:param leeway: Time window in seconds before the actual expiration of the
    authentication token, that the token is considered expired and will
    be refreshed.
:param default_timeout: If settled, every requests will have a default timeout.
)
allow_redirectstimeoutcookiesfilesproxieshooksstreamverifycertjsonc                     [         R                  " U 5        Xl        [        X5        [        R                  " U 4U UUUUUUUUU	U
US.UD6  g )N)session	client_idclient_secrettoken_endpoint_auth_methodrevocation_endpoint_auth_methodscopestateredirect_urir   token_placementupdate_tokenleeway)r   __init__default_timeoutr   r   )r   rC   rD   rE   rF   rG   rH   rI   r   rJ   rK   rL   rN   kwargss                 r   rM   OAuth2Session.__init__[   sd      	. .	
''A,K%+%	
 	
r   c                 (    U R                   " U40 UD6$ )zAlias for fetch_token.)fetch_token)r   r   rO   s      r   fetch_access_token OAuth2Session.fetch_access_token   s    .v..r   c                    > U R                   (       a  UR                  SU R                   5        U(       d*  Uc'  U R                  (       d
  [        5       eU R                  n[
        TU ]  " X4SU0UD6$ )z<Send request with auto refresh token feature (if available).r8   auth)rN   
setdefaultr   r
   
token_authsuperrequest)r   r3   r   withhold_tokenrV   rO   	__class__s         r   rZ   OAuth2Session.request   s[    i)=)=>$,::'))??Dwv@@@@r   )rN   )NNNNNNNNheaderN<   Nr   )FN)r)   r*   r+   r,   r-   r0   client_auth_classr   token_auth_classr   oauth_error_classSESSION_REQUEST_PARAMSrM   rS   rZ   r.   __classcell__)r\   s   @r   r   r   .   sa    8 )!" #'(, #
J/A Ar   N)requestsr   requests.authr   authlib.oauth2.authr   r   authlib.oauth2.clientr   base_clientr	   r
   r   r   utilsr   __all__r   r0   r   r(   r   r   <module>rl      s[     " * ) . + + $ 3 +L
)9 &x ^AL' ^Ar   