3 L(YH@sdZddlmZddlmZddlZddlZddlZyddl Z ddl Z ddl Z Wne k rle dYnXyddlZ dZWne k rdZYnXdZd d Zd d Zd dZddZe jjee jjee jjee jjee jjjeiZereee jjj<ddZ dS)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)_helpersNzoauth2client is not installed.TFz8Unable to convert {} to a google-auth credentials class.cCs2tjjj|j|j|j|j|j|j d}|j |_ |S)aBConverts 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_secretscopes) googleoauth2 credentials CredentialsZ access_tokenrrrrr Z token_expiryZ_expires)r Znew_credentialsrH/private/tmp/pip-build-nl73fm5q/google-auth/google/auth/_oauth2client.py_convert_oauth2_credentials/s  rcCs$|jj}|j|d<tjjjj|S)auConverts 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)Zserialization_datacopyrr r service_accountr Zfrom_service_account_info)r inforrr$_convert_service_account_credentialsGs   rcCstjjj|jdS)aConverts 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 authZcompute_enginer r)r rrr&_convert_gce_app_assertion_credentialsYs rcCstjjjtj|j|jdS)aConverts 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 rZ app_enginer rZstring_to_scopesZscoper)r rrr,_convert_appengine_app_assertion_credentialsgs  rc Cs<t|}y t||Stk r6ttj|YnXdS)aConvert 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_MAPKeyError ValueError_CONVERT_ERROR_TMPLformat)r Zcredentials_classrrrconverts  r )!__doc__ __future__rZ google.authrZgoogle.auth.app_enginer Zgoogle.oauth2.credentialsZgoogle.oauth2.service_accountZoauth2client.clientZ oauth2clientZoauth2client.contrib.gceZoauth2client.service_account ImportErrorZoauth2client.contrib.appengineZ_HAS_APPENGINErrrrrclientZOAuth2CredentialsZGoogleCredentialsrZServiceAccountCredentialsZ_JWTAccessCredentialscontribZgceZAppAssertionCredentialsrZ appenginer rrrrs@