Clerk.Net.DependencyInjection 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Clerk.Net.DependencyInjection --version 1.0.0                
NuGet\Install-Package Clerk.Net.DependencyInjection -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Clerk.Net.DependencyInjection" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Clerk.Net.DependencyInjection --version 1.0.0                
#r "nuget: Clerk.Net.DependencyInjection, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Clerk.Net.DependencyInjection as a Cake Addin
#addin nuget:?package=Clerk.Net.DependencyInjection&version=1.0.0

// Install Clerk.Net.DependencyInjection as a Cake Tool
#tool nuget:?package=Clerk.Net.DependencyInjection&version=1.0.0                

Clerk API Client for .NET

Nuget Nuget

Packages

Clerk.Net: Provides the standalone API Client as a Kiota-generated wrapper over Clerk's OpenAPI spec.

Clerk.Net.DependencyInjection: Extensions to register the ClerkApiClient into your DI container.

These libraries support .NET 6 onwards and are configured as native AoT compatible for .NET 8+ consumers.

Getting Started

Make sure to add your SecretKey to your application configuration, ideally via the dotnet secrets manager.

DI Container Configuration (ASP.NET Core & Worker Services)

  1. Install Clerk.Net.DependencyInjection from Nuget.
  2. Add the following code to your service configuration:
builder.Services.AddClerkApiClient(config =>
{
    config.SecretKey = builder.Configuration["Clerk:SecretKey"]!
});
  1. Request the ClerkApiClient in your services
public class MyBackgroundWorker : BackgroundService
{
    private readonly ClerkApiClient _clerkApiClient;

    public MyBackgroundWorker(ClerkApiClient clerkApiClient)
    {
        _clerkApiClient = clerkApiClient;
    }

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        var invites = await _clerkApiClient.Organizations["org_abc1234"].Invitations.GetAsync(x =>
        {
            x.QueryParameters.Status = "pending";
        });
    }
}

Standalone Client

If you want to use the client by itself, install Clerk.Net and call ClerkApiClientFactory.Create, passing in your secret key.

The returned client should be treated as a singleton and created once for the lifetime of your application.

HttpClient Customization

If you need to configure the underlying HttpClient used by the client, you can do in one of two ways:

  • Configure the IHttpClientBuilder returned by AddClerkApiClient.
  • Pass in a custom HttpClient instance to ClerkApiClientFactory.Create

Testing

For unit testing, see Unit testing Kiota API clients.

Disclaimer

I am not affiliated with nor represent Clerk. All support queries regarding the underlying service should go to Clerk Support.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.7.0 1,105 9/27/2024
1.6.0 2,918 7/7/2024
1.5.0 1,618 5/1/2024
1.4.0 1,784 3/17/2024
1.3.0 750 12/18/2023
1.2.0 184 11/18/2023
1.1.0 105 11/4/2023
1.0.0 91 10/30/2023
0.1.0 155 10/28/2023