Configuration - C# SDK

Configuration - C# SDK

Before you get started with creating your C# application, you need to first authenticate the app with Zoho. And to do that there are some configuration procedures that need to be in place. Basically, the OAuth Client details must be given as a section within the  app.config  file.


Updates for SDK Version 2.0.1+

  1. The SDK is compatible with Visual Studio 2015 .
  2. Also, the sdk will need the application configuration be specified only as a dictionary and not as an app.config file.


Note

  • Only  .Net Core  applications will have the app.config file.
  • For ASP.NET, ASP Web App, ASP Website, etc, please use  configuration dictionary  to configure your application.

Add a section  oauth_configuration  in the app.config file and make sure that the section has the attribute type as ' ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK '. For example

  1. <configuration>
  2. <configSections>
  3.       <section name="oauth_configuration" type="ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK"></section>
  4.       <section name="zcrm_configuration" type="ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK"></section>
  5. </configSections>
  6.       <oauth_configuration>
  7.             <settings>
  8.                   <add key = "client_id" value = "" />
  9.                   <add key = "client_secret" value = "" />
  10.                   <add key = "redirect_uri" value = "" />
  11.                   <add key = "access_type" value = "" />
  12.                   <add key = "iamUrl" value = "" />
  13.                   <add key = "persistence_handler_class" value = ""/>
  14.                   <add key = "mysql_username" value = "" />
  15.                   <add key = "mysql_password" value = "" />
  16.                   <add key = "mysql_database" value = "" />
  17.                   <add key = "mysql_server" value = "" />
  18.                   <add key = "mysql_port" value = "" />
  19.                   <add key = "oauth_tokens_file_path" value = "" />
  20.             </settings>
  21.       </oauth_configuration>
  22.       <zcrm_configuration>
  23.             <settings>
  24.                   <add key = "apiBaseUrl" value = ""/>
  25.                   <add key = "photoUrl" value = ""/>
  26.                   <add key = "apiVersion" value = ""/>
  27.                   <add key = "logFilePath" value = ""/>
  28.                   <add key = "timeout" value = ""/>
  29.                   <add key = "minLogLevel" value = "'"/>
  30.                   <add key = "currentUserEmail" value = "" />
  31.                   <add key = "domainSuffix" value = "" />
  32.             </settings>
  33.       </zcrm_configuration>
  34. </configuration>

  • client_id client_secret  and  redirect_uri  are your OAuth client’s configurations that you get after registering your Zoho client.
  • access_type  will be set to  offline  by default. Access and Refresh tokens will be received only when it is offline.
  • iamUrl  - Url to be used when calling an Oauth accounts. It is used to denote the domain of the user. Url may be:
  • persistence_handler_class  is your implementation of the  IZohoPersistenceHandler  interface, which has handler methods to store OAuth data. This is discussed in the next section.
    • For example: persistence_handler_class=ZCRMSDK.OAuth.ClientApp.ZohoOAuthFilePersistence, ZCRMSDK (or) ZCRMSDK.OAuth.ClientApp.ZohoOAuthDBPersistence, ZCRMSDK (or) your own persistence handler class.
  • If you prefer to use our DB persistence ( ZohoOAuthDBPersistence.cs ) , you need to give the mysql_username and mysql_password keys for mysql connectivity.
    • By default,  mysql_username  = "root",  mysql_password  = "",  mysql_database  = "zohooauth",  mysql_server  = "localhost" and  mysql_port  = "3306".
    • The tokens are generated and placed in the database table automatically(which is explained in the ZohoOauthDBPersistence section) once the authentication process is complete.
  • The  oauth_tokens_file_path  is required if the SDK's File Persistence is used as the persistence handler. It is the path of the file for storing the tokens of the user.
Other than the above OAuth configurations, the SDK also provides options to override certain HTTP request attributes. These configurations should be provided under a section named  zcrm_configuration , in the  app.config  file.

The type of the section should be ' ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK '.

The following are the supported configurations in the zcrm_configuration section:
  • apiBaseUrl  - Url to be used when calling an API. It is used to denote the domain of the user. Url may be:
  • photoUrl  - Url for the image representing the record. The domain might be different based on the  apiBaseUrl . Url may be:
  • apiVersion  is "v2".
  • timeOut  - Represents the request timeout in milliseconds. Let this be omitted or empty if not needed.
  • minLogLevel  - Represents the minimum log level for logging of SDK. The supported values are ALL, INFO, WARNING, ERROR and OFF. The default minimum log level is WARNING.
  • logFilePath  - Represents the file to which the SDK can log. Optional configuration and can be omitted. If omitted, the SDK logs the working in the execution directory of the application under the filename  LogFile.log . Only the path of the file, without the file name, is needed for storing the logs.
  • currentUserEmail  - In case of single user, this configuration can be set.
  • domainSuffix  - Optional configuraion. Provides Multi-DC Support. Ex: com, eu or cn.

Note

If the file path for "logFilePath" is not specified, then the "logFile.log" is created in the "{Project}/bin/Debug/netcoreapp2.1/" folder of the project.



SEE ALSO

Release Notes
    • Related Articles

    • Configuration - Node JS SDK

      Your OAuth Client details should be given to the SDK as a property file. In the SDK, you need to configure a file named oauth_configuration.properties. Please place the respective values in that file. You can place it under resources folder from ...
    • Configuration - Python SDK

      Before you get started with creating your python application, you need to first authenticate the app with Zoho. And to do that there are some configuration procedures that need to be in place. There are two methods in which you can authenticate your ...
    • Configuration - PHP SDK

      To access the CRM services through SDK, the client application must be first authenticated. This can be done by passing a key-value configuration pair to the initialization process. The $configuration array must be created. It will contain the ...
    • Configuration - Java SDK

      Setting up the configuration is a system engineering process, for establishing and maintaining the consistency of the application's performance, functional and physical attributes with its requirements, design and operational information throughout ...
    • Configuration - Android SDK

      Create a New Project Once your client has been registered, you could start with creating your own Android application. In your command line, move to the directory where you want to create your mobile project and execute the following command. ...