!;ihdZddlZ ddlZddlZdZn #e$rdZYnwxYw ddlZn #e$rdZYnwxYw ddlZddl ZdZ n #e$rdZ YnwxYwd dZ d dZ dZ dZd Zd Zd Zd ZdS)z=Helpers for authentication using oauth2client or google-auth.NTFc|tr'tj|||\}}|St d)z'Returns credentials loaded from a file.scopesquota_project_idzAclient_options.credentials_file is only supported in google-auth.)HAS_GOOGLE_AUTHgoogleauthload_credentials_from_fileEnvironmentError)filenamerr credentials_s IC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\googleapiclient/_auth.pycredentials_from_filer)sP ?? V6F@   Q O   ctr&tj||\}}|Str6||t dt jj St d)z(Returns Application Default Credentials.rNzwclient_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.) rrr defaultHAS_OAUTH2CLIENTr oauth2clientclientGoogleCredentialsget_application_default)rrr rs rdefault_credentialsr6s ,,,<-   Q    !1!=". "4LLNNN +   rctrIt|tjjjr%tjj||S |r||S|S#t$r|cYSwxYw)aScopes 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 isinstancerr r Credentialswith_scopes_if_requiredcreate_scoped_required create_scopedAttributeError)r rs r with_scopesr!Ks :k6;3J3VWW {&>>{FSSS 1133 #"00888""       s(A=;A== B  B cddlm}trXt|tjjjr4ttdtj ||S| |S)aaReturns 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#rrrr r rgoogle_auth_httplib2 ValueErrorAuthorizedHttp authorize)r r#s rauthorized_httpr+ds0///// 3:k6;3J3VWW 3  '(  $2;ZZ\\RRRR$$ZZ\\222rctj}trMt|tjjjr)tj |}| |S| |SN) httplib2Httprrrr r rr'Requestrefresh)r refresh_httprequests rrefresh_credentialsr4sh =??L1:k6;3J3VWW1&.|<<""7+++""<000rcht|st|||Sr-)is_validr4apply)r headerss rapply_credentialsr9s4 K )K(((   W % %%rctr+t|tjjjr|jS|jduo|j Sr-) rrrr r rvalid access_tokenaccess_token_expired)r s rr6r6sL :k6;3J3VWW     $D 0 544 rc|dSt|jdr |jjSt|dr&t|jtjs|jSdS)Nr )hasattrr3r rr.rr$s rget_credentials_from_httpr@si |t } - -|'' } % %j (.//tr)NN)__doc__r. google.authrgoogle.auth.credentialsr ImportErrorr'roauth2client.clientrrrr!r+r4r9r6r@rrrGssDC""""OOOOO              *23336 1 1 1&&&        s' &00 ?A A