VOOZH about

URL: https://www.nuget.org/packages/Clerk.Net/1.4.0

⇱ NuGet Gallery | Clerk.Net 1.4.0




Clerk.Net 1.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Clerk.Net --version 1.4.0
 
 
NuGet\Install-Package Clerk.Net -Version 1.4.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" Version="1.4.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Clerk.Net" Version="1.4.0" />
 
Directory.Packages.props
<PackageReference Include="Clerk.Net" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Clerk.Net --version 1.4.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Clerk.Net, 1.4.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.
#:package Clerk.Net@1.4.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Clerk.Net&version=1.4.0
 
Install as a Cake Addin
#tool nuget:?package=Clerk.Net&version=1.4.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Clerk SDK for .NET

👁 Nuget
👁 Nuget

Looking for ASP.NET Core w/ Clerk JWTs? See below.

Packages

Clerk.Net: Provides the standalone API Client as a Kiota-generated wrapper over Clerk's OpenAPI spec. Compatible with .NET 6+ and .NET Framework 4.7.2+.

Clerk.Net.DependencyInjection: Extensions to register the ClerkApiClient into your DI container. Compatible with .NET 6+.

These libraries 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.

What about JWT Auth?

You might have stumbled upon this repo looking for a solution for validating Clerk JWTs, so I'll include the answer here for completion. Configuring JWT auth for Clerk is a tad unusual as they want you to validate the azp parameter instead of specifying an audience. This claim isn't normally validated at the authentication layer, and so you'll need some extra code to get things working:

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
 .AddJwtBearer(x =>
 {
 // Authority is the URL of your clerk instance
 x.Authority = builder.Configuration["Clerk:Authority"];
 x.TokenValidationParameters = new TokenValidationParameters()
 {
 // Disable audience validation as we aren't using it
 ValidateAudience = false,
 NameClaimType = ClaimTypes.NameIdentifier 
 };
 x.Events = new JwtBearerEvents()
 {
 // Additional validation for AZP claim
 OnTokenValidated = context =>
 {
 var azp = context.Principal?.FindFirstValue("azp");
 // AuthorizedParty is the base URL of your frontend.
 if (string.IsNullOrEmpty(azp) || !azp.Equals(builder.Configuration["Clerk:AuthorizedParty"]))
 context.Fail("AZP Claim is invalid or missing");

 return Task.CompletedTask;
 }
 };
 });

Your frontend should call Clerk-JS's getToken as part of its HTTP middleware and append the token (prefixed with Bearer) to the Authorization header, for example:

async onRequestInit({ requestInit }) {
 requestInit.headers = {
 ...requestInit.headers,
 Authorization: `Bearer ${await getToken()}`
 }
}

Disclaimer

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

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 is compatible.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Clerk.Net:

Package Downloads
Clerk.Net.DependencyInjection

Clerk Backend API Wrapper for .NET. This package includes dependency injection extensions.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.15.0 79,872 6/25/2025
1.14.0 6,373 4/21/2025
1.13.0 5,416 3/4/2025
1.12.0 3,323 2/23/2025
1.11.0 10,513 2/8/2025
1.10.0 2,968 1/13/2025
1.9.0 2,141 1/4/2025
1.8.0 4,742 11/26/2024
1.7.0 4,624 9/27/2024
1.6.0 10,392 7/7/2024
1.5.0 5,598 5/1/2024
1.4.0 2,194 3/17/2024
1.3.0 1,131 12/18/2023
1.2.0 387 11/18/2023
1.1.0 530 11/4/2023
1.0.0 425 10/30/2023
0.1.0 566 10/28/2023