예제 #1
0
 def initialize(isToInitializeOAuth, config_dict=None):
     if (config_dict is None):
         raise ZohoOAuthException(
             "Configuration dictionary is mandatory to initialize RestClient"
         )
     mandatory_keys = [
         ZohoOAuthConstants.CLIENT_ID, ZohoOAuthConstants.CLIENT_SECRET,
         ZohoOAuthConstants.REDIRECT_URL, APIConstants.CURRENT_USER_EMAIL
     ]
     try:
         from .RestClient import ZCRMRestClient
     except ImportError:
         from RestClient import ZCRMRestClient
     for key in mandatory_keys:
         if (key not in config_dict):
             if (key != APIConstants.CURRENT_USER_EMAIL or ZCRMRestClient.
                     get_instance().get_current_user_email_id() == None):
                 raise ZohoOAuthException(key + ' is mandatory')
         elif (key in config_dict
               and (config_dict[key] is None or config_dict[key] == "")):
             if (key != APIConstants.CURRENT_USER_EMAIL or ZCRMRestClient.
                     get_instance().get_current_user_email_id() == None):
                 raise ZohoOAuthException(key + ' value is missing')
     ZCRMConfigUtil.set_config_values(config_dict)
     if (isToInitializeOAuth):
         ZohoOAuth.initialize(config_dict)
예제 #2
0
 def initialize(isToInitializeOAuth):
     import os
     from Path import PathIdentifier
     resources_path = os.path.join(PathIdentifier.get_client_library_root(),
                                   'resources', 'configuration.properties')
     filePointer = open(resources_path, "r")
     ZCRMConfigUtil.config_prop_dict = CommonUtil.get_file_content_as_dictionary(
         filePointer)
     if (isToInitializeOAuth):
         ZohoOAuth.initialize()
예제 #3
0
 def initialize(isToInitializeOAuth):
     import os
     ZCRMConfigUtil.config_prop_dict={
         'apiBaseUrl': os.environ['API_BASE_URL'],
         'apiVersion': os.environ['API_VERSION'],
         'sandbox': os.environ['SANDBOX'],
         'applicationLogFilePath': os.environ['APPLICATION_LOG_FILE_PATH'],
         'currentUserEmail': os.environ['CURRENT_USER_EMAIL']
     }
     if(isToInitializeOAuth):
         ZohoOAuth.initialize()
예제 #4
0
 def get_access_token(self):
     try:
         from .RestClient import ZCRMRestClient
     except ImportError:
         from RestClient import ZCRMRestClient
     userEmail=ZCRMRestClient.get_instance().get_current_user_email_id()
     if(userEmail==None and (ZCRMConfigUtil.config_prop_dict['currentUserEmail']==None or ZCRMConfigUtil.config_prop_dict['currentUserEmail'].strip()=='')):
         raise ZCRMException('fetching current user email',400,'Current user should either be set in ZCRMRestClient or in configuration.properties file',APIConstants.STATUS_ERROR)
     elif(userEmail==None):
         userEmail=ZCRMConfigUtil.config_prop_dict['currentUserEmail']
     clientIns=ZohoOAuth.get_client_instance()
     return clientIns.get_access_token(userEmail)
예제 #5
0
    def initialize(isToInitializeOAuth, config_dict=None):
        mandatory_keys = [
            ZohoOAuthConstants.CLIENT_ID, ZohoOAuthConstants.CLIENT_SECRET,
            ZohoOAuthConstants.REDIRECT_URL, APIConstants.CURRENT_USER_EMAIL
        ]
        import os
        try:
            from .Path import PathIdentifier
            from .RestClient import ZCRMRestClient
        except ImportError:
            from Path import PathIdentifier
            from RestClient import ZCRMRestClient

        if (config_dict is None):
            resources_path = os.path.join(
                PathIdentifier.get_client_library_root(), 'resources',
                'configuration.properties')
            filePointer = open(resources_path, "r")
            ZCRMConfigUtil.config_prop_dict = CommonUtil.get_file_content_as_dictionary(
                filePointer)
        else:
            for key in mandatory_keys:
                if (key not in config_dict):
                    if (key != APIConstants.CURRENT_USER_EMAIL
                            or ZCRMRestClient.get_instance().
                            get_current_user_email_id() is None):
                        raise ZohoOAuthException(key + ' is mandatory')
                elif (key in config_dict and
                      (config_dict[key] is None or config_dict[key] == "")):

                    if (key != APIConstants.CURRENT_USER_EMAIL
                            or ZCRMRestClient.get_instance().
                            get_current_user_email_id() is None):
                        raise ZohoOAuthException(key + ' value is missing')
            ZCRMConfigUtil.set_config_values(config_dict)

        if (isToInitializeOAuth):
            ZohoOAuth.initialize(config_dict)