o
    =jz  ã                   @   sh   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ	 G dd„ de	j
ƒZ
G d	d
„ d
e	jƒZdS )aï  OAuth 2.0 Async Credentials.

This module provides credentials based on OAuth 2.0 access and refresh tokens.
These credentials usually access resources on behalf of a user (resource
owner).

Specifically, this is intended to use access tokens acquired using the
`Authorization Code grant`_ and can refresh those tokens using a
optional `refresh token`_.

Obtaining the initial access and refresh token is outside of the scope of this
module. Consult `rfc6749 section 4.1`_ for complete details on the
Authorization Code grant flow.

.. _Authorization Code grant: https://tools.ietf.org/html/rfc6749#section-1.3.1
.. _refresh token: https://tools.ietf.org/html/rfc6749#section-6
.. _rfc6749 section 4.1: https://tools.ietf.org/html/rfc6749#section-4.1
é    )Ú_credentials_async)Ú_helpers)Ú
exceptions)Ú_reauth_async)Úcredentialsc                   @   s8   e Zd ZdZe ej¡dd„ ƒZe ej¡dd„ ƒZ	dS )ÚCredentialsa  Credentials using OAuth 2.0 access and refresh tokens.

    The credentials are considered immutable. If you want to modify the
    quota project, use :meth:`with_quota_project` or ::

        credentials = credentials.with_quota_project('myproject-123)
    c           
   
   Ã   sæ   �| j d u s| jd u s| jd u s| jd u rt d¡‚tj|| j| j | j| j| j| j	| j
d�I d H \}}}}}|| _|| _|| _ | d¡| _|| _	| jrmd|v rot| jƒ}t|d  ¡ ƒ}|| }	|	rqt d d |	¡¡¡‚d S d S d S )NzžThe credentials do not contain the necessary fields need to refresh the access token. You must specify refresh_token, token_uri, client_id, and client_secret.)ZscopesÚ
rapt_tokenZenable_reauth_refreshZid_tokenZscopezUNot all requested scopes were granted by the authorization server, missing scopes {}.z, )Z_refresh_tokenZ
_token_uriZ
_client_idZ_client_secretr   ZRefreshErrorÚreauthZrefresh_grantZ_scopesZ_rapt_tokenZ_enable_reauth_refreshÚtokenÚexpiryÚgetZ	_id_tokenÚ	frozensetÚsplitÚformatÚjoin)
ÚselfÚrequestZaccess_tokenZrefresh_tokenr   Zgrant_responser   Zrequested_scopesZgranted_scopesZ scopes_requested_but_not_granted© r   újC:\Users\psant\Downloads\Anu Raj Backend\school\venv\Lib\site-packages\google/oauth2/_credentials_async.pyÚrefresh2   s\   €ÿþýüÿ
øú
ÿþûzCredentials.refreshc                 Ã   s&   �| j s|  |¡I d H  |  |¡ d S )N)Zvalidr   Úapply)r   r   ÚmethodÚurlÚheadersr   r   r   Úbefore_requestc   s   €zCredentials.before_requestN)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zcopy_docstringr   r   r   r   r   r   r   r   r   )   s    


0r   c                   @   s   e Zd ZdZdS )ÚUserAccessTokenCredentialsa»  Access token credentials for user account.

    Obtain the access token for a given user account or the current active
    user account with the ``gcloud auth print-access-token`` command.

    Args:
        account (Optional[str]): Account to get the access token for. If not
            specified, the current active account will be used.
        quota_project_id (Optional[str]): The project ID used for quota
            and billing.

    N)r   r   r   r   r   r   r   r   r   j   s    r   N)r   Zgoogle.authr   r   r   r   Zgoogle.oauth2r   r	   Zoauth2_credentialsr   r   r   r   r   r   Ú<module>   s   A