Configuration
Authentication

Authentication

The DealCloud SDK uses OAuth2 client credentials for authentication. HTTP calls go through intapp-rest-client (RestClient); advanced options (timeouts, retries, logging) align with that library unless overridden by DealCloudConfig.

This page covers all available authentication methods for the DealCloud SDK.

Quick Start

Use DealCloudConfig (OAuth2 client credentials) and DealCloud.from_config_object():

from dealcloud_sdk import DealCloud, DealCloudConfig
 
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-client-secret",
)
dc = DealCloud.from_config_object(config)

Full options (timeouts, retries, query settings) and vault-backed setups are covered in Configuration Files.

⚠️

Security: Never commit credentials to version control. Load secrets from a vault or environment, or use config files that stay out of git.

📦

Legacy shortcut: DealCloud(site_url=..., client_id=..., client_secret=...) still works for small scripts and migration from older samples; prefer DealCloudConfig for anything you maintain long term.

Choose Your Authentication Method

Select based on your deployment environment:

Deployment TypeRecommended MethodWhy
Kubernetes / ContainersEnvironment VariablesNative secret injection, no file mounting
Azure / AWS / GCPEnvironment Variables + Secrets ManagerCloud-native secret rotation
Enterprise / On-PremJSON/YAML Config FileCentralized config management, full settings
Local Development.env FileEasy to manage, git-ignored
Multi-EnvironmentJSON/YAML with Nested ConfigsSingle file, multiple environments
CI/CD PipelinesEnvironment VariablesInjected by pipeline, no file artifacts
💡

Preference: Both JSON/YAML config files and environment variables support all advanced settings. Choose based on your deployment needs - environment variables work great for containers and CI/CD, while config files are ideal for centralized configuration management.

Authentication Methods

Environment Variables

Best for containerized deployments (Kubernetes, Docker, ECS) and CI/CD pipelines.

from dealcloud_sdk import DealCloud
 
# Uses default environment variable names
dc = DealCloud.from_env()

Default environment variable names:

Required Credentials

VariableDescription
DC_SDK_SITE_URLYour DealCloud site URL
DC_SDK_CLIENT_IDAPI Client ID
DC_SDK_CLIENT_SECRETAPI Client Secret

Optional Configuration Settings

VariableTypeDefaultDescription
DC_SDK_CONNECTOR_TIMEOUT_SECONDSint100HTTP request timeout in seconds
DC_SDK_QUERY_PAGE_SIZEint1000Records per page for row operations
DC_SDK_QUERY_CELL_PAGINATION_LIMITint9000Cells per page for cell operations
DC_SDK_QUERY_DELETE_PAGE_SIZEint10000Records per delete batch
DC_SDK_CONCURRENCY_LIMIT_READint2Max concurrent read requests
DC_SDK_CONCURRENCY_LIMIT_DELETEint2Max concurrent delete requests
DC_SDK_CONCURRENCY_LIMIT_CREATEint2Max concurrent create/update requests
DC_SDK_RETRY_TOO_MANY_REQUESTSint5Retries for HTTP 429
DC_SDK_RETRY_INTERNAL_SERVER_ERRORint2Retries for HTTP 500
DC_SDK_RETRY_SERVICE_UNAVAILABLEint2Retries for HTTP 503
DC_SDK_RETRY_BAD_GATEWAYint2Retries for HTTP 502
DC_SDK_RETRY_GATEWAY_TIMEOUTint2Retries for HTTP 504
DC_SDK_RETRY_BACKOFF_FACTORfloat2.0Exponential backoff multiplier
DC_SDK_RETRY_MAX_BACKOFF_SECONDSfloat300.0Maximum wait between retries

Kubernetes Example

# k8s-deployment.yaml
apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
        - name: my-app
          env:
            # Required credentials
            - name: DC_SDK_SITE_URL
              value: "yoursite.dealcloud.com"
            - name: DC_SDK_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: dealcloud-credentials
                  key: client-id
            - name: DC_SDK_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: dealcloud-credentials
                  key: client-secret
            # Optional: Performance tuning
            - name: DC_SDK_CONNECTOR_TIMEOUT_SECONDS
              value: "120"
            - name: DC_SDK_QUERY_PAGE_SIZE
              value: "2000"
            - name: DC_SDK_CONCURRENCY_LIMIT_READ
              value: "4"
            # Optional: Retry configuration
            - name: DC_SDK_RETRY_TOO_MANY_REQUESTS
              value: "10"

Custom Variable Names

dc = DealCloud.from_env(
    site_url_env_name="MY_DC_URL",
    client_id_env_name="MY_DC_CLIENT",
    client_secret_env_name="MY_DC_SECRET"
)

Local Development with .env Files

With python-dotenv (opens in a new tab):

Minimal configuration (credentials only):

# .env file (add to .gitignore!)
DC_SDK_SITE_URL=yoursite.dealcloud.com
DC_SDK_CLIENT_ID=12345
DC_SDK_CLIENT_SECRET=your-secret

Full configuration (all settings):

# .env file (add to .gitignore!)
DC_SDK_SITE_URL=yoursite.dealcloud.com
DC_SDK_CLIENT_ID=12345
DC_SDK_CLIENT_SECRET=your-secret
 
# Optional: Customize timeouts and performance
DC_SDK_CONNECTOR_TIMEOUT_SECONDS=120
DC_SDK_QUERY_PAGE_SIZE=2000
DC_SDK_CONCURRENCY_LIMIT_READ=4
 
# Optional: Customize retry behavior
DC_SDK_RETRY_TOO_MANY_REQUESTS=10
DC_SDK_RETRY_BACKOFF_FACTOR=2.5
from dotenv import load_dotenv
from dealcloud_sdk import DealCloud
 
load_dotenv()  # Load .env file
dc = DealCloud.from_env()  # Automatically uses all configured environment variables
💡

Full Configuration Support: Environment variables now support all configuration options available in JSON/YAML files. You can mix and match - only set the environment variables you want to customize, and defaults will be used for the rest.

JSON Configuration File (Full Settings)

Best for enterprise deployments requiring full configuration control.

{
  "siteUrl": "yoursite.dealcloud.com",
  "clientId": 12345,
  "clientSecret": "your-secret",
  "connectorTimeoutSeconds": 100,
  "querySettings": {
    "pageSize": 1000
  },
  "responseRetrySettings": {
    "tooManyRequests": 5,
    "internalServerError": 2,
    "backoffFactor": 2
  }
}
dc = DealCloud.from_json("config.json")

This format supports all configuration options including timeouts, pagination, and retry settings.

YAML Configuration File

YAML format for human-readable configuration. Preferred for DevOps teams familiar with Kubernetes/Helm.

# config.yaml
siteUrl: yoursite.dealcloud.com
clientId: 12345
clientSecret: your-secret
connectorTimeoutSeconds: 100
querySettings:
  pageSize: 1000
responseRetrySettings:
  tooManyRequests: 5
  internalServerError: 2
  backoffFactor: 2
dc = DealCloud.from_yaml("config.yaml")
💡

YAML support requires the yaml extra:

  • pip: pip install dealcloud-sdk[yaml]
  • uv: uv add dealcloud-sdk[yaml]
  • poetry: poetry add dealcloud-sdk -E yaml

Pydantic Config Object

For programmatic configuration:

from dealcloud_sdk import DealCloud, DealCloudConfig
 
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-secret",
    connectorTimeoutSeconds=120,
    querySettings={
        "pageSize": 500
    }
)
 
dc = DealCloud.from_config_object(config)

For a config file path, use DealCloud.from_config("dealcloud_config.json") instead.

Configuration Formats

The SDK supports two configuration formats and auto-detects which is being used:

FormatCase StyleFull SettingsRecommended For
camelCasecamelCase✅ YesNew projects
snake_casesnake_case❌ Credentials onlyBackward compatibility
💡

The camelCase format matches our DealCloud .NET SDK, enabling shared config files across Python and .NET projects.

camelCase Format (Recommended)

{
  "siteUrl": "yoursite.dealcloud.com",
  "clientId": 12345,
  "clientSecret": "your-secret",
  "connectorTimeoutSeconds": 100,
  "querySettings": {
    "pageSize": 1000
  },
  "responseRetrySettings": {
    "tooManyRequests": 5,
    "internalServerError": 2,
    "backoffFactor": 2
  }
}

This format supports all advanced configuration options.

snake_case Format (Backward Compatible)

{
  "site_url": "yoursite.dealcloud.com",
  "client_id": 12345,
  "client_secret": "your-secret"
}

Use this if migrating from an older Python SDK version. Advanced settings require the camelCase format.

Token Management

The SDK automatically handles OAuth2 token management:

  • Automatic Token Refresh: Tokens are refreshed before expiration
  • Thread-Safe: Token management is thread-safe for concurrent requests
  • No Manual Management: You never need to handle tokens directly
from dealcloud_sdk import DealCloud, DealCloudConfig
 
# Tokens are managed automatically
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-secret",
)
dc = DealCloud.from_config_object(config)
 
# Make requests without worrying about tokens
data = dc.read_data("Company", output="pandas")  # Token obtained automatically
data2 = dc.read_data("Contact", output="pandas")  # Token reused or refreshed

Multi-Environment Setup

Pattern for managing multiple DealCloud environments:

from dealcloud_sdk import DealCloud
import os
 
def get_client(env: str = "production") -> DealCloud:
    """Get DealCloud client for specified environment."""
    config_map = {
        "production": "config/prod.json",
        "staging": "config/staging.json",
        "development": "config/dev.json"
    }
    
    config_file = config_map.get(env)
    if not config_file:
        raise ValueError(f"Unknown environment: {env}")
    
    return DealCloud.from_json(config_file)
 
# Usage
dc_prod = get_client("production")
dc_staging = get_client("staging")

Security Best Practices

By Deployment Type

Cloud-Native Secrets Management

# AWS - Use Secrets Manager
import boto3
import json
 
def get_dc_client():
    client = boto3.client('secretsmanager')
    secret = json.loads(
        client.get_secret_value(SecretId='dealcloud/prod')['SecretString']
    )
    return DealCloud(
        site_url=secret['siteUrl'],
        client_id=secret['clientId'],
        client_secret=secret['clientSecret']
    )
# Azure - Use Key Vault
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
 
def get_dc_client():
    credential = DefaultAzureCredential()
    kv = SecretClient(vault_url="https://myvault.vault.azure.net/", credential=credential)
    return DealCloud(
        site_url=kv.get_secret("dc-site-url").value,
        client_id=kv.get_secret("dc-client-id").value,
        client_secret=kv.get_secret("dc-client-secret").value
    )

General Guidelines

  1. Never hardcode credentials in source code
  2. Match auth method to deployment - see table above
  3. Restrict file permissions on config files (chmod 600)
  4. Rotate credentials regularly (quarterly recommended)
  5. Use separate credentials for dev/staging/production
  6. Audit API access using DealCloud's activity logs

Next Steps