
    hh                         d Z ddlZ	 ddlZddlZdZn# e$ r dZY nw xY w	 ddlZn# e$ r dZY nw xY w	 ddlZddl	ZdZ
n# e$ r dZ
Y nw xY wddZddZd Zd Zd	 Zd
 Zd Zd ZdS )z=Helpers for authentication using oauth2client or google-auth.    NTFc                 |    t           r't          j                            | ||          \  }}|S t	          d          )z'Returns credentials loaded from a file.scopesquota_project_idzAclient_options.credentials_file is only supported in google-auth.)HAS_GOOGLE_AUTHgoogleauthload_credentials_from_fileEnvironmentError)filenamer   r   credentials_s        {/home/visionen/pythonvenv/lib/python3.11/site-packages/google_api_python_client-2.181.0-py3.11.egg/googleapiclient/_auth.pycredentials_from_filer   )   sP     
??V6F @ 
 
Q O
 
 	
    c                     t           r&t          j                            | |          \  }}|S t          r6| |t          d          t          j        j        	                                S t          d          )z(Returns Application Default Credentials.r   Nzwclient_options.scopes and client_options.quota_project_id are not supported in oauth2client.Please install google-auth.zZNo authentication library is available. Please install either google-auth or oauth2client.)
r   r   r	   defaultHAS_OAUTH2CLIENTr   oauth2clientclientGoogleCredentialsget_application_default)r   r   r   r   s       r   default_credentialsr   6   s     
,,,< - 
 
Q 	 
!1!=".   "4LLNNN+
 
 	
r   c                    t           rIt          | t          j        j        j                  r%t          j        j                            | |          S 	 |                                 r|                     |          S | S # t          $ r | cY S w xY w)a  Scopes the credentials if necessary.

    Args:
        credentials (Union[
            google.auth.credentials.Credentials,
            oauth2client.client.Credentials]): The credentials to scope.
        scopes (Sequence[str]): The list of scopes.

    Returns:
        Union[google.auth.credentials.Credentials,
            oauth2client.client.Credentials]: The scoped credentials.
    )
r   
isinstancer   r	   r   Credentialswith_scopes_if_requiredcreate_scoped_requiredcreate_scopedAttributeError)r   r   s     r   with_scopesr!   K   s      	:k6;3J3VWW 	{&>>{FSSS	1133 #"00888"" 	 	 		s   (A= ;A= =BBc                    ddl m} t          rXt          | t          j        j        j                  r4t          t          d          t          j
        |  |                      S |                      |                      S )aa  Returns an http client that is authorized with the given credentials.

    Args:
        credentials (Union[
            google.auth.credentials.Credentials,
            oauth2client.client.Credentials]): The credentials to use.

    Returns:
        Union[httplib2.Http, google_auth_httplib2.AuthorizedHttp]: An
            authorized http client.
    r   )
build_httpNzCredentials from google.auth specified, but google-api-python-client is unable to use these credentials unless google-auth-httplib2 is installed. Please install google-auth-httplib2.http)googleapiclient.httpr#   r   r   r   r	   r   r   google_auth_httplib2
ValueErrorAuthorizedHttp	authorize)r   r#   s     r   authorized_httpr+   d   s     0///// 
3:k6;3J3VWW 
3'(   $2;ZZ\\RRRR$$ZZ\\222r   c                     t          j                    }t          rMt          | t          j        j        j                  r)t          j	        |          }| 
                    |          S | 
                    |          S N)httplib2Httpr   r   r   r	   r   r   r'   Requestrefresh)r   refresh_httprequests      r   refresh_credentialsr4      sh    
 =??L 1:k6;3J3VWW 1&.|<<""7+++""<000r   c                 h    t          |           st          |            |                     |          S r-   )is_validr4   apply)r   headerss     r   apply_credentialsr9      s4    K   )K(((W%%%r   c                     t           r+t          | t          j        j        j                  r| j        S | j        d uo| j         S r-   )	r   r   r   r	   r   r   validaccess_tokenaccess_token_expired)r   s    r   r6   r6      sL     
:k6;3J3VWW 
   $D0 544	
r   c                     | d S t          | j        d          r| j        j        S t          | d          r&t          | j        t          j                  s| j        S d S )Nr   )hasattrr3   r   r   r.   r   r$   s    r   get_credentials_from_httpr@      si    |t	}	-	- |''	}	%	% j(./ /  tr   )NN)__doc__r.   google.authr   google.auth.credentialsr   ImportErrorr'   r   oauth2client.clientr   r   r   r!   r+   r4   r9   r6   r@    r   r   <module>rG      ss   D C """"OO   OOO           

 

 

 


 
 
 
*  23 3 36
1 
1 
1& & &
 
 

 
 
 
 
s'   
 & 00
? A	A	