HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/google/oauth2/__pycache__/utils.cpython-310.pyc
o

�h��@srdZddlZddlZddlZddlZddlmZGdd�dej�ZGdd�de	�Z
Gdd	�d	ejd
�Zdd�Z
dS)
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@seZdZdZdZdS)�ClientAuthType��N)�__name__�
__module__�__qualname__�basic�request_body�rr�F/usr/local/CyberCP/lib/python3.10/site-packages/google/oauth2/utils.pyr5src@seZdZdZddd�ZdS)�ClientAuthenticationz�Defines the client authentication credentials for basic and request-body
    types based on https://tools.ietf.org/html/rfc6749#section-2.3.1.
    NcCs||_||_||_dS)a�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)�selfrrrrrr�__init__?s

zClientAuthentication.__init__�N)rrr�__doc__rrrrrr
:sr
cs@eZdZdZd�fdd�	Z	ddd�Zddd�Zd	d
�Z�ZS)
�OAuthClientAuthHandlerzUAbstract class for handling client authentication in OAuth-based
    operations.
    Ncstt|���||_dS)z�Instantiates an OAuth client authentication handler.

        Args:
            client_authentication (Optional[google.oauth2.utils.ClientAuthentication]):
                The OAuth client authentication credentials if available.
        N)�superrr�_client_authentication)r�client_authentication��	__class__rrrSs
zOAuthClientAuthHandler.__init__cCs&|�||�|dur|�|�dSdS)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_tokenrrr�#apply_client_authentication_options]s�z:OAuthClientAuthHandler.apply_client_authentication_optionscCsv|durd||d<dS|jdur7|jjtjur9|jj}|jjp!d}t�d||f����	�}d||d<dSdSdS)Nz	Bearer %s�
Authorization�z%s:%szBasic %s)
rrrr	rr�base64�	b64encode�encode�decode)rrr�username�password�credentialsrrrrps
���z4OAuthClientAuthHandler._inject_authenticated_headerscCsR|jdur%|jjtjur'|durt�d��|jj|d<|jjp d|d<dSdSdS)Nz*HTTP request does not support request-bodyrr!r)rrrr
r�
OAuthErrorrr)rr
rrrrs
��

��z9OAuthClientAuthHandler._inject_authenticated_request_bodyr)NN)	rrrrrrrr�
__classcell__rrrrrNs
�
r)�	metaclassc	Cs�z4g}t�|�}|�d�|d��d|vr |�d�|d��d|vr.|�d�|d��d�|�}Wn
ttfyA|}Ynwt�||��)z�Translates 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�
ValueErrorrr))�
response_body�error_components�
error_data�
error_detailsrrr�handle_error_response�s

�r:)r�abcr"�enumr/�google.authr�Enumr�objectr
�ABCMetarr:rrrr�<module>sB