def initialize(config_dict=None): try: ZohoOAuth.set_config_values(config_dict) if((ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH] =="") and \ (ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_PATH not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ZohoOAuthConstants.CUSTOM_PERSISTENCE_HANDLER_PATH] == "")): if (ZohoOAuthConstants.DATABASE_PORT not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PORT] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PORT] = "3306" if (ZohoOAuthConstants.DATABASE_USERNAME not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_USERNAME] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_USERNAME] = "root" if (ZohoOAuthConstants.DATABASE_PASSWORD not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PASSWORD] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PASSWORD] = "" oAuthParams = ZohoOAuthParams.get_instance( ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_ID], ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_SECRET], ZohoOAuth.configProperties[ZohoOAuthConstants.REDIRECT_URL]) ZohoOAuthClient.get_instance(oAuthParams) except Exception as ex: OAuthLogger.add_log( 'Exception occured while reading oauth configurations', logging.ERROR, ex) raise ex
def initialize(): try: try: from .Path import PathIdentifier except ImportError: from Path import PathIdentifier import os #dirSplit=os.path.split(PathIdentifier.get_client_library_root()) #resources_path = os.path.join(dirSplit[0],'resources','oauth_configuration.properties') resources_path = os.path.join( PathIdentifier.get_client_library_root(), 'resources', 'oauth_configuration.properties') filePointer = open(resources_path, "r") ZohoOAuth.configProperties = ZohoOAuth.get_file_content_as_dictionary( filePointer) oAuthParams = ZohoOAuthParams.get_instance( ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_ID], ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_SECRET], ZohoOAuth.configProperties[ZohoOAuthConstants.REDIRECT_URL]) ZohoOAuthClient.get_instance(oAuthParams) except Exception as ex: OAuthLogger.add_log( 'Exception occured while reading oauth configurations', logging.ERROR, ex) raise ex
def initialize(config_dict=None): try: try: from .Path import PathIdentifier except ImportError: from Path import PathIdentifier import os if (config_dict is None): #dirSplit=os.path.split(PathIdentifier.get_client_library_root()) #resources_path = os.path.join(dirSplit[0],'resources','oauth_configuration.properties') resources_path = os.path.join( PathIdentifier.get_client_library_root(), 'resources', 'oauth_configuration.properties') filePointer = open(resources_path, "r") ZohoOAuth.configProperties = ZohoOAuth.get_file_content_as_dictionary( filePointer) else: ZohoOAuth.set_config_values(config_dict) if (ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.TOKEN_PERSISTENCE_PATH] == ""): if (ZohoOAuthConstants.DATABASE_HOST not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_HOST] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_HOST] = "127.0.0.1" if (ZohoOAuthConstants.DATABASE_PORT not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PORT] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PORT] = "3306" if (ZohoOAuthConstants.DATABASE_USERNAME not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_USERNAME] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_USERNAME] = "root" if (ZohoOAuthConstants.DATABASE_PASSWORD not in ZohoOAuth.configProperties or ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PASSWORD] == ""): ZohoOAuth.configProperties[ ZohoOAuthConstants.DATABASE_PASSWORD] = "" oAuthParams = ZohoOAuthParams.get_instance( ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_ID], ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_SECRET], ZohoOAuth.configProperties[ZohoOAuthConstants.REDIRECT_URL]) ZohoOAuthClient.get_instance(oAuthParams) except Exception as ex: OAuthLogger.add_log( 'Exception occured while reading oauth configurations', logging.ERROR, ex) raise ex
def initialize(): try: ZohoOAuth.configProperties = { 'client_id': os.environ['CLIENT_ID'], 'client_secret': os.environ['CLIENT_SECRET'], 'redirect_uri': os.environ['REDIRECT_URI'], 'accounts_url': os.environ['ACCOUNTS_URL'], 'token_persistence_path': os.environ['TOKEN_PERSISTENCE_PATH'], 'access_type': os.environ['ACCESS_TYPE'] } oAuthParams = ZohoOAuthParams.get_instance( ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_ID], ZohoOAuth.configProperties[ZohoOAuthConstants.CLIENT_SECRET], ZohoOAuth.configProperties[ZohoOAuthConstants.REDIRECT_URL]) ZohoOAuthClient.get_instance(oAuthParams) except Exception as ex: OAuthLogger.add_log( 'Exception occured while reading oauth configurations', logging.ERROR, ex) raise ex