+
    P(iI                         ^ RI Ht ^ RIHt ^RIHt ^RIHt ^RIHt ^RI	H
t
 ^RI	Ht ^RI	Ht ^R	I	Ht ^R
IHt ^RIHt RRRR/t ! R R4      tR tR# )    )generate_token)
url_decode)
ClientAuth)	TokenAuth)OAuth2Error)!parse_authorization_code_response)parse_implicit_response)prepare_grant_uri)prepare_token_request)prepare_revoke_token_request)create_s256_code_challengeAcceptzapplication/jsonzContent-Typez/application/x-www-form-urlencoded;charset=UTF-8c                     a  ] tR t^t o Rt]t]t]	t
Rt. tRR ltR tR t]R 4       t]P$                  R 4       tRR ltRR	 ltRR
 ltRR ltRR ltRR ltRR ltR tR tR R ltR!R ltRR ltR tR t R"R lt!R t"Rt#V t$R# )#OAuth2Clienta  Construct a new OAuth 2 protocol client.

:param session: Requests session object to communicate with
                authorization server.
:param client_id: Client ID, which you get from client registration.
:param client_secret: Client Secret, which you get from registration.
:param token_endpoint_auth_method: client authentication method for
    token 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 code_challenge_method: PKCE method name, only S256 is supported.
: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.
Nc                   Wn         W n        W0n        Wpn        Vf   V'       d   RpMRpW@n        Vf   V'       d   RpMRpWPn        W`n        Wn        Wn        V P                  WV 4      V n
        Wn        VP                  RR 4      pV'       d   \        R4      hWn        R\        4       R\        4       R\        4       R\        4       R	\        4       /V n        / V n        Wn        R # )
Nclient_secret_basicnonetoken_updaterz<update token has been redesigned, checkout the documentationaccess_token_responserefresh_token_requestrefresh_token_responserevoke_token_requestintrospect_token_request)session	client_idclient_secretstatetoken_endpoint_auth_methodrevocation_endpoint_auth_methodscoperedirect_uricode_challenge_methodtoken_auth_class
token_authupdate_tokenpop
ValueErrormetadatasetcompliance_hook_auth_methodsleeway)selfr   r   r   r   r   r    r   r!   r"   tokentoken_placementr%   r,   r(   r   s   &&&&&&&&&&&&&&, [/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/authlib/oauth2/client.py__init__OAuth2Client.__init__5   s    " "*
%--B*-3**D'*22G/28//N,
(%:"//M( _d;N  ! $SU#SU$ce"CE& 
      c                    \        V\        4      '       d    V^,          V P                  V^ ,          &   R# WP                  VP                  &   R# )z]Extend client authenticate for token endpoint.

:param auth: an instance to sign the request
N)
isinstancetupler+   name)r-   auths   &&r0   register_client_auth_method(OAuth2Client.register_client_auth_methodu   s;    
 dE""*.q'DtAw',0tyy)r3   c                    \        V\        4      '       d$   WP                  9   d   V P                  V,          pV P                  V P                  V P
                  VR 7      # ))r   r   auth_method)r5   strr+   client_auth_classr   r   )r-   r<   s   &&r0   client_authOAuth2Client.client_auth   sU    k3''K;M;M,M,,[9K%%nn,,# & 
 	
r3   c                .    V P                   P                  # N)r$   r.   r-   s   &r0   r.   OAuth2Client.token   s    $$$r3   c                <    V P                   P                  V4       R # rB   )r$   	set_token)r-   r.   s   &&r0   r.   rD      s    !!%(r3   c           	        Vf   \        4       pV P                  P                  RR4      pVP                  RV4      pRV9  d   V P                  VR&   RV9  d   V P
                  VR&   V'       d6   VR8X  d/   V P                  R8X  d   \        V4      VR&   V P                  VR&   V P                   F2  pWd9  g   K  W`P                  9   g   K  V P                  V,          WF&   K4  	  \        V3RV P                  RVR	V/VB pWr3# )
ah  Generate an authorization URL and state.

:param url: Authorization endpoint url, must be HTTPS.
:param state: An optional state string for CSRF protection. If not
              given it will be generated for you.
:param code_verifier: An optional code_verifier for code challenge.
:param kwargs: Extra parameters to include.
:return: authorization_url, state
response_typecoder!   r    S256code_challenger"   r   r   )r   r(   getr&   r!   r    r"   r   EXTRA_AUTHORIZE_PARAMSr
   r   )r-   urlr   code_verifierkwargsrH   kuris   &&&&,   r0   create_authorization_url%OAuth2Client.create_authorization_url   s    ="$E))/6B

?MB'%)%6%6F>"& "jjF7O '**f4'A-'PF#$.2.H.HF*+,,A1#5 MM!,	 -  
nn
 (
 	

 
 zr3   c                l   T;'       g    V P                   pVP                  RR4      p	V	'       d   RV	9   d   V P                  W4      # V P                  V4      p
V	'       d#   RV	9   d   Rp\	        V	VR7      pVR,          VR&   Vf   V P
                  P                  R4      pVf   \        V4      pW`P
                  R&   V P                  ! W&3/ VB pVf   V P                  V P                  4      pVf   \        pVf   V P
                  P                  R	4      pV P                  ! V3R
VRVRVRV/V
B # )a;  Generic method for fetching an access token from the token endpoint.

:param url: Access Token endpoint URL, if not configured,
            ``authorization_response`` is used to extract token from
            its fragment (implicit way).
:param body: Optional application/x-www-form-urlencoded body to add the
             include in the token request. Prefer kwargs over body.
:param method: The HTTP method used to make the request. Defaults
               to POST, but may also be GET. Other methods should
               be added as needed.
:param headers: Dict to default request headers with.
:param auth: An auth tuple or method as accepted by requests.
:param grant_type: Use specified grant_type to fetch token.
:param state: Optional "state" value to fetch token.
:return: A :class:`OAuth2Token` object (a dict too).
authorization_responseN#zcode=authorization_code)r   rI   
grant_typetoken_endpointbodyr8   methodheaders)r   r&   token_from_fragment_extract_session_request_paramsr   r(   rL   _guess_grant_type_prepare_token_endpoint_bodyr?   r   DEFAULT_HEADERS_fetch_token)r-   rN   r[   r\   r]   r8   rY   r   rP   rV   session_kwargsparamss   &&&&&&&&,   r0   fetch_tokenOAuth2Client.fetch_token   sK   6 ##!',Dd!K!c-C&C++,BJJ==fE!g1G&G-J6&F $F^F6N**<8J*62J*4MM,'00LVL<##D$C$CDD?%G;--##$45C  

!%
.4
>E
IW
 	
r3   c                    \        W4      pR V9   d*   V P                  VR ,          VP                  R4      R7      hW0n        V# )errorerror_descriptionri   description)r	   oauth_error_classrL   r.   )r-   rV   r   r.   s   &&& r0   r^    OAuth2Client.token_from_fragment   sL    '(>Fe((Gn%))<O2P )   
r3   c                
   V P                  V4      pT;'       g    V P                  P                  R4      pRV9  d"   V P                  '       d   V P                  VR&   \	        RV3RV/VB pVf   \
        P                  4       pVf   V P                  P                  R4      pV P                  R,           F  pV! WV4      w  rpK  	  Vf   V P                  V P                  4      pV P                  ! V3RVRVRVRV/VB # )a  Fetch a new access token using a refresh token.

:param url: Refresh Token endpoint, must be HTTPS.
:param refresh_token: The refresh_token to use.
:param body: Optional application/x-www-form-urlencoded body to add the
             include in the token request. Prefer kwargs over body.
:param auth: An auth tuple or method as accepted by requests.
:param headers: Dict to default request headers with.
:return: A :class:`OAuth2Token` object (a dict too).
refresh_tokenr    rZ   r   r[   r]   r8   )r_   r.   rL   r    r   rb   copyr(   r*   r?   r   _refresh_token)	r-   rN   rp   r[   r8   r]   rP   rd   hooks	   &&&&&&,  r0   rp   OAuth2Client.refresh_token  s'    ==fE%HH)H& TZZZ"jjF7O$T
1>
BH
 ?%**,G;--##$45C(()@AAD!%cD!9C$ B <##D$C$CDD""
'
 
 	

 
 
 	
r3   c                   Vf   V P                   pVP                  V P                  R7      '       g   R# VP                  R4      pV P                  P                  R4      pV'       d   V'       d   V P                  W2R7       R# V P                  P                  R4      R8X  dC   VR,          pV P                  VRR	7      pV P                  '       d   V P                  WTR
7       R# R # )N)r,   Trp   rZ   rp   rY   client_credentialsaccess_token)rY   )rx   )r.   
is_expiredr,   rL   r(   rp   rf   r%   )r-   r.   rp   rN   rx   	new_tokens   &&    r0   ensure_active_token OAuth2Client.ensure_active_token-  s    =JJEt{{33		/2mm 01Ss@]]|,0DD 0L((9M(NI   !!)!G Er3   c                |    Vf   V P                  V P                  4      pV P                  ! RV3RVRVRVRVRV/VB # )a^  Revoke token method defined via `RFC7009`_.

:param url: Revoke Token endpoint, must be HTTPS.
:param token: The token to be revoked.
:param token_type_hint: The type of the token that to be revoked.
                        It can be "access_token" or "refresh_token".
:param body: Optional application/x-www-form-urlencoded body to add the
             include in the token request. Prefer kwargs over body.
:param auth: An auth tuple or method as accepted by requests.
:param headers: Dict to default request headers with.
:return: Revocation Response

.. _`RFC7009`: https://tools.ietf.org/html/rfc7009
r   r.   token_type_hintr[   r8   r]   )r?   r   _handle_token_hintr-   rN   r.   r~   r[   r8   r]   rP   s   &&&&&&&,r0   revoke_tokenOAuth2Client.revoke_token>  st    0 <##D$H$HID&&"	
 	
 ,		

 	
 	
 	
 	
 		
r3   c                |    Vf   V P                  V P                  4      pV P                  ! RV3RVRVRVRVRV/VB # )a  Implementation of OAuth 2.0 Token Introspection defined via `RFC7662`_.

:param url: Introspection Endpoint, must be HTTPS.
:param token: The token to be introspected.
:param token_type_hint: The type of the token that to be revoked.
                        It can be "access_token" or "refresh_token".
:param body: Optional application/x-www-form-urlencoded body to add the
             include in the token request. Prefer kwargs over body.
:param auth: An auth tuple or method as accepted by requests.
:param headers: Dict to default request headers with.
:return: Introspection Response

.. _`RFC7662`: https://tools.ietf.org/html/rfc7662
r   r.   r~   r[   r8   r]   )r?   r   r   r   s   &&&&&&&,r0   introspect_tokenOAuth2Client.introspect_tokenc  st    0 <##D$C$CDD&&&	
 	
 ,		

 	
 	
 	
 	
 		
r3   c                    VR8X  d(   V P                   P                  P                  V4       R# WP                  9  d   \	        RWP                  4      hV P                  V,          P                  V4       R# )a  Register a hook for request/response tweaking.

Available hooks are:

* access_token_response: invoked before token parsing.
* refresh_token_request: invoked before refreshing token.
* refresh_token_response: invoked before refresh token parsing.
* protected_request: invoked before making a request.
* revoke_token_request: invoked before revoking a token.
* introspect_token_request: invoked before introspecting a token.
protected_requestNzHook type %s is not in %s.)r$   hooksaddr*   r'   )r-   	hook_typers   s   &&&r0   register_compliance_hook%OAuth2Client.register_compliance_hook  sg     ++OO!!%%d+000,i9M9M  	Y'++D1r3   c                    VP                   R 8  d   VP                  4        VP                  4       pRV9   d*   V P                  VR,          VP	                  R4      R7      hW n        V P
                  # )i  ri   rj   rk   )status_coderaise_for_statusjsonrm   rL   r.   )r-   respr.   s   && r0   parse_response_token!OAuth2Client.parse_response_token  sk    s"!!#		e((Gn%))<O2P )   
zzr3   c           	        VP                  4       R 8X  d7   V P                  P                  ! V3R\        \	        V4      4      RVRV/VB pMMRV9   d   RP                  W.4      pMRP                  W.4      pV P                  P                  ! WQ3RVRV/VB pV P                  R,           F  pV! V4      pK  	  V P                  V4      # )POSTdatar]   r8   ?&r   )	upperr   postdictr   joinrequestr*   r   )	r-   rN   r[   r]   r8   r\   rP   r   rs   s	   &&&&&&,  r0   rc   OAuth2Client._fetch_token  s     <<>V#<<$$z$/0:AHLPVD czhh{+hh{+<<''%,37;AD (()@AAD:D B ((..r3   c           	     L   V P                   ! V3R VRVRV/VB pV P                  R,           F  pV! V4      pK  	  V P                  V4      p	RV	9  d   W P                  R&   \	        V P
                  4      '       d   V P                  V P                  VR7       V P                  # )r[   r8   r]   r   rp   rv   )
_http_postr*   r   r.   callabler%   )
r-   rN   rp   r[   r]   r8   rP   r   rs   r.   s
   &&&&&&,   r0   rr   OAuth2Client._refresh_token  s     sTTDT'TVT(()ABBD:D C ))$/%'*7JJ'D%%&&djjFzzr3   c                   VfQ   V P                   '       d?   V P                   P                  R4      ;'       g    V P                   P                  R4      pVf   Rp\        W4WW4      w  rWV P                  V,           F  p	V	! W'V4      w  r'pK  	  Vf   V P	                  V P
                  4      pV P                  V4      p
V P                  ! W%3RVRV/V
B # )Nrp   rx    r8   r]   )r.   rL   r   r*   r?   r   r_   r   )r-   rs   rN   r.   r~   r[   r8   r]   rP   r*   rd   s   &&&&&&&&,  r0   r   OAuth2Client._handle_token_hint  s     =TZZZJJNN?3UUtzz~~n7UE<D4D
  $33D99O!0t!DC$  : <##D$H$HID==fEsWtWWWWWr3   c                    VR 8X  d#   RV9  d   V P                   VR&   \        W!3/ VB # RV9  d"   V P                  '       d   V P                  VR&   \        W!3/ VB # )rX   r!   r    )r!   r   r    )r-   r[   rY   rP   s   &&&,r0   ra   )OAuth2Client._prepare_token_endpoint_body  s`    --V+)-):):~&(DVDD& TZZZ"jjF7O$Z@@@r3   c                f    / pV P                    F  pW19   g   K  VP                  V4      W#&   K   	  V# )zDExtract parameters for session object from the passing ``**kwargs``.)SESSION_REQUEST_PARAMSr&   )r-   rP   rvrQ   s   &&  r0   r_   ,OAuth2Client._extract_session_request_params  s2    ,,A{

1 - 	r3   c           	     l    V P                   P                  ! V3R \        \        V4      4      RVRV/VB # )r   r]   r8   )r   r   r   r   )r-   rN   r[   r8   r]   rP   s   &&&&&,r0   r   OAuth2Client._http_post   sF    ||  
:d+,
6=
DH
LR
 	
r3   c                
    V = R # rB   )r   rC   s   &r0   __del__OAuth2Client.__del__  s    Lr3   )r+   r   r   r"   r*   r,   r(   r!   r   r    r   r   r.   r$   r   r%   )response_modenonceprompt
login_hint)NNNNNNNNNheaderN<   )NN)Nr   r   NNNNrB   )NNr   NN)NNNNN)r   NNr   )Nr   NN)NNN)%__name__
__module____qualname____firstlineno____doc__r   r>   r   r#   r   rm   rM   r   r1   r9   r?   propertyr.   setterrS   rf   r^   rp   r{   r   r   r   r   rc   rr   r   ra   r_   r   r   __static_attributes____classdictcell__)__classdict__s   @r0   r   r      s     2 # #O>@1
 % % \\) )'R?
B(
T"#
J#
J2,
/*"X<A

 r3   r   c                 D    R V 9   d   RpV# RV 9   d   RV 9   d   RpV# RpV# )rI   rX   usernamepasswordrw    )rP   rY   s   & r0   r`   r`   	  sB    )

 	 
v	*"6
  *
r3   N)authlib.common.securityr   authlib.common.urlsr   r8   r   r   baser   rfc6749.parametersr   r	   r
   r   rfc7009r   rfc7636r   rb   r   r`   r   r3   r0   <module>r      sM    2 *    A 7 1 5 1 /  Er rjr3   