Configuration

Before you get started with creating your Python application, you need to register your client and authenticate the app with Zoho.

Mandatory Keys

    • user
    • environment
    • token

Optional Keys

    • logger
    • store
    • sdk_config
    • proxy
    • resource_path

Follow the below steps to configure the SDK.

  1. Create an instance of UserSignature that identifies the current user.

    
    from zcrmsdk.src.com.zoho.crm.api.user_signature import UserSignature
    
    # Create an UserSignature instance that takes user Email as parameter
    user = UserSignature(email='abc@zoho.com')
    
  2. Configure the API environment which decides the domain and the URL to make API calls.

    
    from zcrmsdk.src.com.zoho.crm.api.dc import USDataCenter
    
    """
    Configure the environment
    which is of the pattern Domain.Environment
    Available Domains: USDataCenter, EUDataCenter, INDataCenter, CNDataCenter, AUDataCenter
    Available Environments: PRODUCTION(), DEVELOPER(), SANDBOX()
    """
    environment = USDataCenter.PRODUCTION()
    
  3. Create an instance of OAuthToken with the information that you get after registering your Zoho client.

    
    from zcrmsdk.src.com.zoho.api.authenticator.oauth_token import OAuthToken
    
    """
    Create a Token instance that takes the following parameters
    1 -> OAuth client id.
    2 -> OAuth client secret.
    3 -> Grant token.
    4 -> Refresh token.
    5 -> OAuth redirect URL. Default value is None
    6 -> id
    7 -> Access token
    """
    token = OAuthToken(client_id='clientId', client_secret='clientSecret', grant_token='grant_token', refresh_token="refresh_token", redirect_url='redirectURL', id="id", access_token="access_token")
    
  4. Create an instance of the Logger Class to log exception and API information.By default, the SDK constructs a Logger instance with level - INFO and file_path - (sdk_logs.log, created in the current working directory

    
    from zcrmsdk.src.com.zoho.api.logger import Logger
    
      """
      Create an instance of Logger Class that takes two parameters
      1 -> Level of the log messages to be logged. Can be configured by typing Logger.Levels "." and choose any level from the list displayed.
      2 -> Absolute file path, where messages need to be logged.
      """
      logger = Logger.get_instance(level=Logger.Levels.INFO, file_path="/Users/user_name/Documents/python_sdk_log.log")
    
  5. Create an instance of TokenStore to persist tokens, used for authenticating all the requests. By default, the SDK creates the sdk_tokens.txt created in the current working directory) to persist the tokens.

    
    from zcrmsdk.src.com.zoho.api.authenticator.store import DBStore, FileStore
    
    """
    DBStore takes the following parameters
    1 -> DataBase host name. Default value "localhost"
    2 -> DataBase name. Default value "zohooauth"
    3 -> DataBase user name. Default value "root"
    4 -> DataBase password. Default value ""
    5 -> DataBase port number. Default value "3306"
    6 -> DataBase table name. Default value "oauthtoken"
    """
    store = DBStore()
    
    #store = DBStore(host='host_name', database_name='database_name', user_name='user_name', password='password', port_number='port_number', table_name = "table_name")
    
    """
    FileStore takes the following parameter
    1 -> Absolute file path of the file to persist tokens
    """
    #store = FileStore(file_path='/Users/username/Documents/python_sdk_tokens.txt')
    
  6. Create an instance of SDKConfig containing the SDK configuration.

    
    from zcrmsdk.src.com.zoho.crm.api.sdk_config import SDKConfig
    
    """
    By default, the SDK creates the SDKConfig instance
    auto_refresh_fields (Default value is False)
      if True - all the modules' fields will be auto-refreshed in the background, every hour.
      if False - the fields will not be auto-refreshed in the background. The user can manually delete the file(s) or refresh the fields using methods from ModuleFieldsHandler(zcrmsdk/src/com/zoho/crm/api/util/module_fields_handler.py)
    
    pick_list_validation (Default value is True)
      A boolean field that validates user input for a pick list field and allows or disallows the addition of a new value to the list.
      if True - the SDK validates the input. If the value does not exist in the pick list, the SDK throws an error.
      if False - the SDK does not validate the input and makes the API request with the user’s input to the pick list
    
    connect_timeout (Default value is None) 
      A  Float field to set connect timeout
    
    read_timeout (Default value is None) 
      A  Float field to set read timeout
    """
    config = SDKConfig(auto_refresh_fields=True, pick_list_validation=False, connect_timeout=None, read_timeout=None)
    
  7. The path containing the absolute directory path to store user specific files containing module fields information. By default, the SDK stores the user-specific files within a folder in the current working directory.Set the absolute directory path to store user specific files containing module fields information in resourcePath

    
    resource_path = '/Users/user_name/Documents/python-app'
    
  8. Create an instance of RequestProxy containing the proxy properties of the user.

    
    from zcrmsdk.src.com.zoho.crm.api.request_proxy import RequestProxy
    
    """
    RequestProxy takes the following parameters
    1 -> Host
    2 -> Port Number
    3 -> User Name. Default value is None
    4 -> Password. Default value is an empty string
    """
    request_proxy = RequestProxy(host='proxyHost', port=80)
    request_proxy = RequestProxy(host='proxyHost', port=80, user='userName', password='password')
    
  9. Initialize the SDK and make API calls.