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+
- The SDK is compatible with Visual Studio 2015 .
- 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
- <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.