o
    ~j6h                     @   s\   d Z ddlmZ ddlmZ ddlmZ G dd deZG dd deZG d	d
 d
eZdS )z(Interfaces for asynchronous credentials.    )_helpers)
exceptions)_BaseCredentialsc                       s:   e Zd ZdZ fddZdddZdd Zd	d
 Z  ZS )Credentialsa^  Base class for all asynchronous credentials.

    All credentials have a :attr:`token` that is used for authentication and
    may also optionally set an :attr:`expiry` to indicate when the token will
    no longer be valid.

    Most credentials will be :attr:`invalid` until :meth:`refresh` is called.
    Credentials can do this automatically before the first HTTP request in
    :meth:`before_request`.

    Although the token and expiration will change as the credentials are
    :meth:`refreshed <refresh>` and used, credentials should be considered
    immutable. Various credentials will accept configuration such as private
    keys, scopes, and other options. These options are not changeable after
    construction. Some classes will provide mechanisms to copy the credentials
    with modifications such as :meth:`ScopedCredentials.with_scopes`.
    c                    s   t t|   d S N)superr   __init__)self	__class__ j/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/auth/aio/credentials.pyr   +   s   zCredentials.__init__Nc                    s   | j ||d dS )zApply the token to the authentication header.

        Args:
            headers (Mapping): The HTTP request headers.
            token (Optional[str]): If specified, overrides the current access
                token.
        )tokenN)_applyr	   headersr   r   r   r   apply.   s   zCredentials.applyc                    s
   t d)a   Refreshes the access token.

        Args:
            request (google.auth.aio.transport.Request): The object used to make
                HTTP requests.

        Raises:
            google.auth.exceptions.RefreshError: If the credentials could
                not be refreshed.
        zRefresh must be implemented)NotImplementedErrorr	   requestr   r   r   refresh8   s   zCredentials.refreshc                    s   |  |I dH  dS )a  Performs credential-specific before request logic.

        Refreshes the credentials if necessary, then calls :meth:`apply` to
        apply the token to the authentication header.

        Args:
            request (google.auth.aio.transport.Request): The object used to make
                HTTP requests.
            method (str): The request's HTTP method or the RPC method being
                invoked.
            url (str): The request's URI or the RPC service's URI.
            headers (Mapping): The request's headers.
        Nr   r	   r   methodurlr   r   r   r   before_requestE   s   zCredentials.before_requestr   )	__name__
__module____qualname____doc__r   r   r   r   __classcell__r   r   r
   r   r      s    

r   c                       sD   e Zd ZdZ fddZeedd Zeedd Z	  Z
S )StaticCredentialsa  Asynchronous Credentials representing an immutable access token.

    The credentials are considered immutable except the tokens which can be
    configured in the constructor ::

        credentials = StaticCredentials(token="token123")

    StaticCredentials does not support :meth `refresh` and assumes that the configured
    token is valid and not expired. StaticCredentials will never attempt to
    refresh the token.
    c                    s   t t|   || _dS )zB
        Args:
            token (str): The access token.
        N)r   r!   r   r   )r	   r   r
   r   r   r   c   s   
zStaticCredentials.__init__c                       t d)Nz'Static credentials cannot be refreshed.r   InvalidOperationr   r   r   r   r   k   s   
zStaticCredentials.refreshc                    s   |  |I d H  d S r   r   r   r   r   r   r   q   s   z StaticCredentials.before_request)r   r   r   r   r   r   copy_docstringr   r   r   r    r   r   r
   r   r!   V   s    
r!   c                   @   s*   e Zd ZdZdd Zd	ddZdd ZdS )
AnonymousCredentialszAsynchronous Credentials that do not provide any authentication information.

    These are useful in the case of services that support anonymous access or
    local service emulators that do not use credentials.
    c                    r"   )zVRaises :class:``InvalidOperation``, anonymous credentials cannot be
        refreshed.z*Anonymous credentials cannot be refreshed.r#   r   r   r   r   r   }   s   
zAnonymousCredentials.refreshNc                    s   |dur
t ddS )zAnonymous credentials do nothing to the request.

        The optional ``token`` argument is not supported.

        Raises:
            google.auth.exceptions.InvalidValue: If a token was specified.
        Nz+Anonymous credentials don't support tokens.)r   InvalidValuer   r   r   r   r      s   
zAnonymousCredentials.applyc                    s   dS )z0Anonymous credentials do nothing to the request.Nr   r   r   r   r   r      s   z#AnonymousCredentials.before_requestr   )r   r   r   r   r   r   r   r   r   r   r   r&   v   s
    
r&   N)	r   google.authr   r   google.auth._credentials_baser   r   r!   r&   r   r   r   r   <module>   s   > 