HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/google/oauth2/__pycache__/utils.cpython-37.pyc
B

��f��@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�D/opt/alt/python37/lib/python3.7/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�	Zddd�Zd
dd�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)rZclient_authentication)�	__class__rrrSszOAuthClientAuthHandler.__init__cCs"|�||�|dkr|�|�dS)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_optionscCsl|dk	rd||d<nR|jdk	rh|jjtjkrh|jj}|jjp@d}t�d||f����	�}d||d<dS)Nz	Bearer %s�
Authorization�z%s:%szBasic %s)
rrrr	rr�base64�	b64encode�encode�decode)rrr�username�password�credentialsrrrrps
z4OAuthClientAuthHandler._inject_authenticated_headerscCsL|jdk	rH|jjtjkrH|dkr,t�d��n|jj|d<|jjpBd|d<dS)Nz*HTTP request does not support request-bodyrrr)rrrr
r�
OAuthErrorrr)rr
rrrrs
z9OAuthClientAuthHandler._inject_authenticated_request_body)N)NN)N)	rrrrrrrr�
__classcell__rr)rrrNs


r)�	metaclassc	Cs�yhg}t�|�}|�d�|d��d|kr@|�d�|d��d|kr\|�d�|d��d�|�}Wnttfk
r�|}YnXt�||��dS)	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 {}�errorZerror_descriptionz: {}Z	error_uriz - {}rN)	�json�loads�append�format�join�KeyError�
ValueErrorrr&)Z
response_bodyZerror_componentsZ
error_dataZ
error_detailsrrr�handle_error_response�s


r1)r�abcr�enumr*Zgoogle.authr�Enumr�objectr
�ABCMetarr1rrrr�<module>)sB