Ë
    ”Âis  ã                   óÌ   — 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dl	mZ dd	l	mZ dd
l	mZ ddlmZ ddgZ G d„ dee«      Z G d„ dee«      Z G d„ dee«      Zy)é    )ÚSession)ÚAuthBase)Ú
ClientAuth)Ú	TokenAuth)ÚOAuth2Clienté   )ÚInvalidTokenError)ÚMissingTokenError)Ú
OAuthError)ÚUnsupportedTokenTypeErroré   )Úupdate_session_configureÚOAuth2SessionÚ
OAuth2Authc                   ó   — e Zd ZdZd„ Zd„ Zy)r   zFSign requests for OAuth 2.0, currently only bearer token is supported.c                 ó|   — | j                   r0| j                   j                  | j                  «      s
t        «       ‚y y ©N)ÚclientÚensure_active_tokenÚtokenr	   )Úselfs    úk/var/www/timesheet/venv/lib/python3.12/site-packages/authlib/integrations/requests_client/oauth2_session.pyr   zOAuth2Auth.ensure_active_token   s/   € Ø�;Š;˜tŸ{™{×>Ñ>¸t¿z¹zÔJÜ#Ó%Ð%ð  Kˆ;ó    c                 ó  — | j                  «        	 | j                  |j                  |j                  |j                  «      \  |_        |_        |_        |S # t
        $ r }dt        |«      › �}t        |¬«      |‚d }~ww xY w)NzUnsupported token_type: )Údescription)r   ÚprepareÚurlÚheadersÚbodyÚKeyErrorÚstrr   )r   ÚreqÚerrorr   s       r   Ú__call__zOAuth2Auth.__call__   sz   € Ø× Ñ Ô"ð	PØ-1¯\©\Ø—‘˜Ÿ™ c§h¡hó.Ñ*ˆCŒG�S”[ #¤(ð ˆ
øô ò 	PØ4´S¸³Z°LÐAˆKÜ+¸ÔDÈ%ÐOûð	Pús   ’AA Á	BÁ!A<Á<BN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   © r   r   r   r      s   „ ÙPò&ó	r   c                   ó   — e Zd ZdZd„ Zy)ÚOAuth2ClientAuthzAAttaches OAuth Client Authentication to the given Request object.c                 ó¤   — | j                  |j                  |j                  |j                  |j                  «      \  |_        |_        |_        |S r   )r   Úmethodr   r   r   )r   r"   s     r   r$   zOAuth2ClientAuth.__call__'   s=   € Ø)-¯©Ø�J‰J˜Ÿ™ §¡¨c¯h©hó*
Ñ&ˆŒ�”˜cœhð ˆ
r   N)r%   r&   r'   r(   r$   r)   r   r   r+   r+   $   s
   „ ÙKór   r+   c                   ó\   ‡ — e Zd ZdZeZeZeZ	dZ
	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdˆ fd„	Zˆ xZS )	r   aË  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                 óš   — t        j                  | «       || _        t        | |«       t	        j                  | f| |||||||||	|
|dœ|¤Ž y )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   r;   r<   r=   r>   r?   r@   rA   r   rB   rC   rD   rF   Úkwargss                 r   rE   zOAuth2Session.__init__[   sh   € ô  	×Ñ˜ÔØ.ˆÔÜ   vÔ.ä×ÑØð	
àØØ'Ø'AØ,KØØØ%ØØ+Ø%Øñ	
ð ó	
r   c                 ó(   —  | j                   |fi |¤ŽS )zAlias for fetch_token.)Úfetch_token)r   r   rG   s      r   Úfetch_access_tokenz OAuth2Session.fetch_access_token€   s   € àˆt×Ñ Ñ. vÑ.Ð.r   c                 óÆ   •— | j                   r|j                  d| j                   «       |s$|€"| j                  s
t        «       ‚| j                  }t        ‰| �  ||fd|i|¤ŽS )z<Send request with auto refresh token feature (if available).r0   Úauth)rF   Ú
setdefaultr   r
   Ú
token_authÚsuperÚrequest)r   r-   r   Úwithhold_tokenrL   rG   Ú	__class__s         €r   rP   zOAuth2Session.request„   s]   ø€ à×ÒØ×Ñ˜i¨×)=Ñ)=Ô>Ù $ ,Ø—:’:Ü'Ó)Ð)Ø—?‘?ˆDÜ‰w‰˜v sÑ@°Ð@¸Ñ@Ð@r   )NNNNNNNNÚheaderNé<   Nr   )FN)r%   r&   r'   r(   r+   Úclient_auth_classr   Útoken_auth_classr   Úoauth_error_classÚSESSION_REQUEST_PARAMSrE   rJ   rP   Ú__classcell__)rR   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   r+   r   r)   r   r   ú<module>ra      s[   ðÝ Ý "å *Ý )Ý .å +Ý +Ý $Ý 3Ý +à˜LÐ
)€ô�˜9ô ô&�x ô ô^A�L 'õ ^Ar   