o
    ~j6h                  
   @   s  d Z ddlmZ ddlmZ ddlZddlZddlZddl	Zzddl
ZddlZddlZW n ey= Z zededZ[ww zddlZdZW n eyQ   dZY nw dZd	d
 Zdd Zdd Zdd ZejjeejjeejjeejjeejjjeiZ eree ejj!j< dd Z"dS )zHelpers for transitioning from oauth2client to google-auth.

.. warning::
    This module is private as it is intended to assist first-party downstream
    clients with the transition from oauth2client to google-auth.
    )absolute_import)_helpersNzoauth2client is not installed.TFz8Unable to convert {} to a google-auth credentials class.c                 C   s2   t jjj| j| j| j| j| j| j	d}| j
|_|S )aB  Converts to :class:`google.oauth2.credentials.Credentials`.

    Args:
        credentials (Union[oauth2client.client.OAuth2Credentials,
            oauth2client.client.GoogleCredentials]): The credentials to
            convert.

    Returns:
        google.oauth2.credentials.Credentials: The converted credentials.
    )tokenrefresh_token	token_uri	client_idclient_secretscopes)googleoauth2credentialsCredentialsaccess_tokenr   r   r   r   r	   token_expiry_expires)r   new_credentials r   h/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/auth/_oauth2client.py_convert_oauth2_credentials0   s   	r   c                 C   s$   | j  }| j|d< tjjj|S )au  Converts to :class:`google.oauth2.service_account.Credentials`.

    Args:
        credentials (Union[
            oauth2client.service_account.ServiceAccountCredentials,
            oauth2client.service_account._JWTAccessCredentials]): The
            credentials to convert.

    Returns:
        google.oauth2.service_account.Credentials: The converted credentials.
    r   )serialization_datacopyr   r
   r   service_accountr   from_service_account_info)r   infor   r   r   $_convert_service_account_credentialsI   s   

r   c                 C   s   t jjj| jdS )a  Converts to :class:`google.auth.compute_engine.Credentials`.

    Args:
        credentials (oauth2client.contrib.gce.AppAssertionCredentials): The
            credentials to convert.

    Returns:
        google.oauth2.service_account.Credentials: The converted credentials.
    )service_account_email)r
   authcompute_enginer   r   r   r   r   r   &_convert_gce_app_assertion_credentialsZ   s   
r   c                 C   s   t jjjt| j| jdS )a  Converts to :class:`google.auth.app_engine.Credentials`.

    Args:
        credentials (oauth2client.contrib.app_engine.AppAssertionCredentials):
            The credentials to convert.

    Returns:
        google.oauth2.service_account.Credentials: The converted credentials.
    )r	   service_account_id)r
   r   
app_enginer   r   string_to_scopesscoper    r   r   r   r   ,_convert_appengine_app_assertion_credentialsi   s   
r$   c              
   C   sD   t | }zt| | W S  ty! } z
tt|}||d}~ww )a  Convert oauth2client credentials to google-auth credentials.

    This class converts:

    - :class:`oauth2client.client.OAuth2Credentials` to
      :class:`google.oauth2.credentials.Credentials`.
    - :class:`oauth2client.client.GoogleCredentials` to
      :class:`google.oauth2.credentials.Credentials`.
    - :class:`oauth2client.service_account.ServiceAccountCredentials` to
      :class:`google.oauth2.service_account.Credentials`.
    - :class:`oauth2client.service_account._JWTAccessCredentials` to
      :class:`google.oauth2.service_account.Credentials`.
    - :class:`oauth2client.contrib.gce.AppAssertionCredentials` to
      :class:`google.auth.compute_engine.Credentials`.
    - :class:`oauth2client.contrib.appengine.AppAssertionCredentials` to
      :class:`google.auth.app_engine.Credentials`.

    Returns:
        google.auth.credentials.Credentials: The converted credentials.

    Raises:
        ValueError: If the credentials could not be converted.
    N)type_CLASS_CONVERSION_MAPKeyError
ValueError_CONVERT_ERROR_TMPLformat)r   credentials_class
caught_excnew_excr   r   r   convert   s   r.   )#__doc__
__future__r   google.authr   google.auth.app_enginer
   google.auth.compute_enginegoogle.oauth2.credentialsgoogle.oauth2.service_accountoauth2client.clientoauth2clientoauth2client.contrib.gceoauth2client.service_accountImportErrorr,   oauth2client.contrib.appengine_HAS_APPENGINEr)   r   r   r   r$   clientOAuth2CredentialsGoogleCredentialsr   ServiceAccountCredentials_JWTAccessCredentialscontribgceAppAssertionCredentialsr&   	appenginer.   r   r   r   r   <module>   sL   

