
    (phh                         S r SSKr SSKrSSKrSr SSKr SSKrSSK	rSr
SS jrSS jrS rS rS	 rS
 rS rS rg! \ a    Sr N7f = f! \ a    Sr N@f = f! \ a    Sr
 NCf = f)z=Helpers for authentication using oauth2client or google-auth.    NTFc                 r    [         (       a"  [        R                  R                  XUS9u  p4U$ [	        S5      e)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        H/var/www/html/venv/lib/python3.13/site-packages/googleapiclient/_auth.pycredentials_from_filer   )   sA    ??6F @ 
 O
 	
    c                     [         (       a!  [        R                  R                  XS9u  p#U$ [        (       a9  U c  Ub  [        S5      e[        R                  R                  R                  5       $ [        S5      e)z(Returns Application Default Credentials.r   zwclient_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    ,, - 
 		!1!=".  ""44LLNN+
 	
r   c                 F   [         (       a\  [        U [        R                  R                  R
                  5      (       a)  [        R                  R                  R                  X5      $  U R                  5       (       a  U R                  U5      $ U $ ! [         a    U s $ f = f)aa  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;;3J3J3V3VWW{{&&>>{SS	1133"0088"" 		s   )%B B B B c                    SSK Jn  [        (       a^  [        U [        R
                  R                  R                  5      (       a+  [        c  [        S5      e[        R                  " X" 5       S9$ U R                  U" 5       5      $ )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_httpzCredentials 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   sj     0:k6;;3J3J3V3VWW'(  $22;Z\RR$$Z\22r   c                    [         R                  " 5       n[        (       aZ  [        U [        R
                  R                  R                  5      (       a'  [        R                  " U5      nU R                  U5      $ U R                  U5      $ N)httplib2Httpr   r   r   r	   r   r   r'   Requestrefresh)r   refresh_httprequests      r   refresh_credentialsr4      sb    
 ==?L:k6;;3J3J3V3VWW&..|<""7++""<00r   c                 Z    [        U 5      (       d  [        U 5        U R                  U5      $ r-   )is_validr4   apply)r   headerss     r   apply_credentialsr9      s&    K  K(W%%r   c                     [         (       a?  [        U [        R                  R                  R
                  5      (       a  U R                  $ U R                  S L=(       a    U R                  (       + $ r-   )	r   r   r   r	   r   r   validaccess_tokenaccess_token_expired)r   s    r   r6   r6      sU    :k6;;3J3J3V3VWW    $$D0 5444	
r   c                     U c  g [        U R                  S5      (       a  U R                  R                  $ [        U S5      (       a5  [        U R                  [        R
                  5      (       d  U R                  $ g )Nr   )hasattrr3   r   r   r.   r   r$   s    r   get_credentials_from_httpr@      sf    |	}	-	-||'''	}	%	%j(../ / r   )NN)__doc__r.   google.authr   google.auth.credentialsr   ImportErrorr'   r   oauth2client.clientr   r   r   r!   r+   r4   r9   r6   r@    r   r   <module>rG      s    D "O 



*236
1&

K  O
      s1   
? A 
A A
	A
AAA&%A&