Skip to content

About

A thread-safe singleton HttpClient for Zoho's OpenAPI integration.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Soenneker.Zoho.HttpClients

Provides cached HttpClient instances configured for Zoho CRM OAuth access tokens and data-center API origins.

Installation

dotnet add package Soenneker.Zoho.HttpClients

Configuration

{
  "Zoho": {
    "AccessToken": "your-oauth-access-token",
    "ClientBaseUrl": "https://www.zohoapis.com/crm/v8/"
  }
}

The US CRM v8 base URL is used when ClientBaseUrl is omitted. Use the API domain returned by Zoho's token response for other data centers, such as https://www.zohoapis.eu/crm/v8/. Zoho:ApiKey remains supported as a legacy alias for Zoho:AccessToken.

The default authorization header is Authorization: Zoho-oauthtoken {token}. AuthHeaderName and AuthHeaderValueTemplate are available for nonstandard integrations.

Registration

services.AddZohoOpenApiHttpClientAsSingleton();

Scoped registration is also available:

services.AddZohoOpenApiHttpClientAsScoped();

Usage

public sealed class ZohoUserReader
{
    private readonly IZohoOpenApiHttpClient _zoho;

    public ZohoUserReader(IZohoOpenApiHttpClient zoho)
    {
        _zoho = zoho;
    }

    public async Task<string> GetUsers(CancellationToken cancellationToken)
    {
        HttpClient client = await _zoho.Get(cancellationToken);
        return await client.GetStringAsync("users?type=AllUsers", cancellationToken);
    }
}

Pass connection values explicitly when serving multiple Zoho tenants or data centers:

HttpClient tenantClient = await zohoHttpClient.Get(
    tenantAccessToken,
    "https://www.zohoapis.eu/crm/v8/",
    cancellationToken);

The provider caches a separate client per access-token/base-URL pair and removes the clients it owns when disposed. It does not obtain or refresh OAuth tokens; Zoho access tokens expire and should be refreshed by the application.

About

A thread-safe singleton HttpClient for Zoho's OpenAPI integration.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages