Authentication

Authentication

DealCloudSDK's main entrypoint is the Client class. When it is instantiated, the object is scoped to a given DealCloud environment, by passing the site URL and API credentials as arguments:

using DealCloudSDK;
 
var dc = new Client(
    "client.dealcloud.com",
    12345,
    "secret"
);
⚠️

Whilst suitable for local development, the above implementation is insecure if you keep code in online repositories such as GitHub. Please see the below examples for more secure implementations.

Securely loading credentials using the IConfiguration interface

The IConfiguration interface can be used to load configuration values for the DealCloudSDK, where the following parameters are available:

siteUrl
clientId
clientSecret

For example, using a JSON configuration file.

using DealCloudSDK;
using Microsoft.Extensions.Configuration;
 
// initialise Ivar configuration object
config = new ConfigurationBuilder()
    .AddJsonFile("environment_config.json")
    .Build();
    
// initialise Client, using the IConfiguration object as an argument.
var dc = new Client(config);