+
    oi                         R t ^ RIt^ RIt^ RIt^ RIt^ RIHt  ! R R]P                  4      t ! R R]	4      t
 ! R R]P                  R	7      tR
 tR# )a'  OAuth 2.0 Utilities.

This module provides implementations for various OAuth 2.0 utilities.
This includes `OAuth error handling`_ and
`Client authentication for OAuth flows`_.

OAuth error handling
--------------------
This will define interfaces for handling OAuth related error responses as
stated in `RFC 6749 section 5.2`_.
This will include a common function to convert these HTTP error responses to a
:class:`google.auth.exceptions.OAuthError` exception.


Client authentication for OAuth flows
-------------------------------------
We introduce an interface for defining client authentication credentials based
on `RFC 6749 section 2.3.1`_. This will expose the following
capabilities:

    * Ability to support basic authentication via request header.
    * Ability to support bearer token authentication via request header.
    * Ability to support client ID / secret authentication via request body.

.. _RFC 6749 section 2.3.1: https://tools.ietf.org/html/rfc6749#section-2.3.1
.. _RFC 6749 section 5.2: https://tools.ietf.org/html/rfc6749#section-5.2
N)
exceptionsc                       ] tR t^5t^t^tRtR# )ClientAuthType N)__name__
__module____qualname____firstlineno__basicrequest_body__static_attributes__r       v/Users/tonyclaw/.openclaw/workspace/scripts/youtube-playlists/venv/lib/python3.14/site-packages/google/oauth2/utils.pyr   r   5   s    ELr   r   c                   .   a  ] tR t^:t o RtRR ltRtV tR# )ClientAuthenticationzDefines the client authentication credentials for basic and request-body
types based on https://tools.ietf.org/html/rfc6749#section-2.3.1.
Nc                *    Wn         W n        W0n        R# )aH  Instantiates a client authentication object containing the client ID
and secret credentials for basic and response-body auth.

Args:
    client_auth_type (google.oauth2.oauth_utils.ClientAuthType): The
        client authentication type.
    client_id (str): The client ID.
    client_secret (Optional[str]): The client secret.
Nclient_auth_type	client_idclient_secret)selfr   r   r   s   &&&&r   __init__ClientAuthentication.__init__?   s     !1"*r   r   N)r   r   r   r	   __doc__r   r   __classdictcell__)__classdict__s   @r   r   r   :   s     + +r   r   c                   T   a a ] tR t^Nt oRtRV 3R lltRR ltRR ltR tRt	Vt
V ;t# )	OAuthClientAuthHandlerzMAbstract class for handling client authentication in OAuth-based
operations.
c                8   < \         \        V `  4        Wn        R# )zInstantiates an OAuth client authentication handler.

Args:
    client_authentication (Optional[google.oauth2.utils.ClientAuthentication]):
        The OAuth client authentication credentials if available.
N)superr   r   _client_authentication)r   client_authentication	__class__s   &&r   r   OAuthClientAuthHandler.__init__S   s     	$d46&;#r   c                V    V P                  W4       Vf   V P                  V4       R# R# )a|  Applies client authentication on the OAuth request's headers or POST
body.

Args:
    headers (Mapping[str, str]): The HTTP request header.
    request_body (Optional[Mapping[str, str]]): The HTTP request body
        dictionary. For requests that do not support request body, this
        is None and will be ignored.
    bearer_token (Optional[str]): The optional bearer token.
N)_inject_authenticated_headers"_inject_authenticated_request_body)r   headersr   bearer_tokens   &&&&r   #apply_client_authentication_options:OAuthClientAuthHandler.apply_client_authentication_options]   s+     	**7A33LA  r   c                   Ve   RV,          VR&   R # V P                   e   V P                   P                  \        P                  J d~   V P                   P                  pV P                   P
                  ;'       g    Rp\        P                  ! V: RV: 2P                  4       4      P                  4       pRV,          VR&   R # R # R # )Nz	Bearer %sAuthorization :zBasic %s)
r!   r   r   r
   r   r   base64	b64encodeencodedecode)r   r(   r)   usernamepasswordcredentialss   &&&   r   r&   4OAuthClientAuthHandler._inject_authenticated_headersp   s    #'2\'AGO$''3++<<@T@TT22<<H22@@FFBH **$h/779fh  (2K'?GO$ U 4r   c                &   V P                   e   V P                   P                  \        P                  J dY   Vf   \        P
                  ! R4      hV P                   P                  VR&   V P                   P                  ;'       g    RVR&   R # R # R # )Nz*HTTP request does not support request-bodyr   r.   r   )r!   r   r   r   r   
OAuthErrorr   r   )r   r   s   &&r   r'   9OAuthClientAuthHandler._inject_authenticated_request_body   s    ''3++<<**+ # ++@  -1,G,G,Q,Q[)//==CC _-+ 4r   )r!   r   )NN)r   r   r   r	   r   r   r*   r&   r'   r   r   __classcell__)r#   r   s   @@r   r   r   N   s%     <B&@ r   r   )	metaclassc                    . p\         P                  ! V 4      pVP                  RP                  VR,          4      4       RV9   d(   VP                  RP                  VR,          4      4       RV9   d(   VP                  RP                  VR,          4      4       RP	                  V4      p\        P                  ! W04      h  \
        \        3 d    T p L+i ; i)zTranslates an error response from an OAuth operation into an
OAuthError exception.

Args:
    response_body (str): The decoded response data.

Raises:
    google.auth.exceptions.OAuthError
zError code {}errorerror_descriptionz: {}	error_uriz - {}r.   )	jsonloadsappendformatjoinKeyError
ValueErrorr   r9   )response_bodyerror_components
error_dataerror_detailss   &   r   handle_error_responserL      s    &ZZ.
 6 6z'7J KL*,##FMM*=P2Q$RS*$##GNN:k3J$KL 01
 


== j! &%&s   B,C CC)r   abcr0   enumrA   google.authr   Enumr   objectr   ABCMetar   rL   r   r   r   <module>rS      sM   8     "
TYY 
+6 +(?s{{ ?D>r   