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.
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
- <configuration>
- <configSections>
- <section name="oauth_configuration" type="ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK"></section>
- <section name="zcrm_configuration" type="ZCRMSDK.CRM.Library.Common.ConfigFileHandler.ConfigFileSection, ZCRMSDK"></section>
- </configSections>
- <oauth_configuration>
- <settings>
- <add key = "client_id" value = "" />
- <add key = "client_secret" value = "" />
- <add key = "redirect_uri" value = "" />
- <add key = "access_type" value = "" />
- <add key = "iamUrl" value = "" />
- <add key = "persistence_handler_class" value = ""/>
- <add key = "mysql_username" value = "" />
- <add key = "mysql_password" value = "" />
- <add key = "mysql_database" value = "" />
- <add key = "mysql_server" value = "" />
- <add key = "mysql_port" value = "" />
- <add key = "oauth_tokens_file_path" value = "" />
- </settings>
- </oauth_configuration>
- <zcrm_configuration>
- <settings>
- <add key = "apiBaseUrl" value = ""/>
- <add key = "photoUrl" value = ""/>
- <add key = "apiVersion" value = ""/>
- <add key = "logFilePath" value = ""/>
- <add key = "timeout" value = ""/>
- <add key = "minLogLevel" value = "'"/>
- <add key = "currentUserEmail" value = "" />
- <add key = "domainSuffix" value = "" />
- </settings>
- </zcrm_configuration>
- </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.
Related Articles
Configuration - PHP SDK
Before you get started with creating your php 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 - 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 ...
C# SDK - An Overview
C# SDK offers a way to create client C# applications that can be integrated with Zoho CRM. This SDK makes the access and use of necessary CRM APIs with ease. In other words, it serves as a wrapper for the REST APIs, making it easier to use the ...
Initialization - C# SDK
Now the app is ready to be initialized after defining configuration file/dictionary for your app. Generating Grant tokens For a Single User(self-authorized) For self client apps, the self authorized grant token should be generated from the Zoho ...
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 ...