Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
546 changes: 324 additions & 222 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ generation:
oAuth2ClientCredentialsEnabled: true
oAuth2PasswordEnabled: true
hoistGlobalSecurity: true
schemas:
allOfMergeStrategy: shallowMerge
requestBodyFieldName: ""
tests:
generateTests: true
generateNewTests: false
skipResponseBodyAssertions: false
csharp:
version: 0.13.0
version: 0.14.0
additionalDependencies:
- package: Microsoft.AspNetCore
version: 2.3.0
Expand All @@ -34,6 +37,7 @@ csharp:
defaultErrorName: SDKError
disableNamespacePascalCasingApr2024: true
dotnetVersion: net8.0
enableCancellationToken: false
enableSourceLink: true
flattenGlobalSecurity: true
flatteningOrder: parameters-first
Expand Down
18 changes: 9 additions & 9 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
speakeasyVersion: 1.628.7
speakeasyVersion: 1.653.0
sources:
clerk-backend-api-OAS:
sourceNamespace: clerk-openapi
sourceRevisionDigest: sha256:28dad6f5eba89eda61b12068caead24aee0c775a3ed54d828c788adcf848fea9
sourceBlobDigest: sha256:906fd13c3a276c610cf5fc9f778e7ed83448cd9366179dc32a86de1320bd07fe
sourceRevisionDigest: sha256:c2c6ab8c4ff4517e23971b57ad56df2b8d811171bef623e0714e8071843bc04b
sourceBlobDigest: sha256:5e8bc9d932d2c4226fc20d5ed7ff34316327db4a92b4fae650ecffd120f194bc
tags:
- latest
- speakeasy-sdk-regen-1756771581
- "2025-04-10"
- speakeasy-sdk-regen-1761696400
- "2025-11-10"
targets:
clerk-backend-api:
source: clerk-backend-api-OAS
sourceNamespace: clerk-openapi
sourceRevisionDigest: sha256:28dad6f5eba89eda61b12068caead24aee0c775a3ed54d828c788adcf848fea9
sourceBlobDigest: sha256:906fd13c3a276c610cf5fc9f778e7ed83448cd9366179dc32a86de1320bd07fe
sourceRevisionDigest: sha256:c2c6ab8c4ff4517e23971b57ad56df2b8d811171bef623e0714e8071843bc04b
sourceBlobDigest: sha256:5e8bc9d932d2c4226fc20d5ed7ff34316327db4a92b4fae650ecffd120f194bc
codeSamplesNamespace: clerk-backend-api-oas-csharp-code-samples
codeSamplesRevisionDigest: sha256:dd3184e33fabb79c32ba77ecad9f9a7e7ba1a6549386c1c9266854a91c1beda7
codeSamplesRevisionDigest: sha256:0e48b293cface580098eb1be753a1a8a4e24a506dfa05967395302cfe9f906f9
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
sources:
clerk-backend-api-OAS:
inputs:
- location: https://raw.githubusercontent.com/clerk/openapi-specs/refs/heads/main/bapi/2025-04-10.yml
- location: https://raw.githubusercontent.com/clerk/openapi-specs/refs/heads/main/bapi/2025-11-10.yml
overlays:
- location: ./examples.yaml
- location: https://raw.githubusercontent.com/clerk/openapi-specs/refs/heads/main/.speakeasy/bapi/fixes.yml
Expand Down
175 changes: 163 additions & 12 deletions NUGET.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ Some exceptions in this SDK include an additional `Payload` field, which will co
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Components;
using Clerk.BackendAPI.Models.Errors;
using Clerk.BackendAPI.Models.Operations;
using System.Collections.Generic;

var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");

try
{
var res = await sdk.AwsCredentials.DeleteAsync(id: "<id>");
VerifyClientRequestBody req = new VerifyClientRequestBody() {
Token = "jwt_token_example",
};

var res = await sdk.Clients.VerifyAsync(req);

// handle response
}
Expand Down Expand Up @@ -180,17 +185,17 @@ catch (System.Net.Http.HttpRequestException ex)
* [`System.Net.Http.HttpRequestException`](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestexception): Network connectivity error. For more details about the underlying cause, inspect the `ex.InnerException`.

* Inheriting from [`SDKBaseError`](./src/Clerk/BackendAPI/Models/Errors/SDKBaseError.cs):
* [`CreateM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/CreateM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
* [`GetM2MTokensResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
* [`RevokeM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/RevokeM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
* [`VerifyM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
* [`VerifyOAuthAccessTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyOAuthAccessTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 159 methods.*
* [`GetM2MTokensM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensM2mResponseBody.cs): 403 Forbidden. Status code `403`. Applicable to 1 of 159 methods.*
* [`GetM2MTokensM2mResponseResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensM2mResponseResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
* [`RevokeM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/RevokeM2MTokenM2mResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
* [`VerifyM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyM2MTokenM2mResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
* [`VerifyOAuthAccessTokenOauthAccessTokensResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyOAuthAccessTokenOauthAccessTokensResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 159 methods.*
* [`CreateM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/CreateM2MTokenM2mResponseBody.cs): 409 Conflict. Status code `409`. Applicable to 1 of 159 methods.*
* [`CreateM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/CreateM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 158 methods.*
* [`GetM2MTokensResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 158 methods.*
* [`RevokeM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/RevokeM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 158 methods.*
* [`VerifyM2MTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyM2MTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 158 methods.*
* [`VerifyOAuthAccessTokenResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyOAuthAccessTokenResponseBody.cs): 400 Bad Request. Status code `400`. Applicable to 1 of 158 methods.*
* [`GetM2MTokensM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensM2mResponseBody.cs): 403 Forbidden. Status code `403`. Applicable to 1 of 158 methods.*
* [`GetM2MTokensM2mResponseResponseBody`](./src/Clerk/BackendAPI/Models/Errors/GetM2MTokensM2mResponseResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 158 methods.*
* [`RevokeM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/RevokeM2MTokenM2mResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 158 methods.*
* [`VerifyM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyM2MTokenM2mResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 158 methods.*
* [`VerifyOAuthAccessTokenOauthAccessTokensResponseBody`](./src/Clerk/BackendAPI/Models/Errors/VerifyOAuthAccessTokenOauthAccessTokensResponseBody.cs): 404 Not Found. Status code `404`. Applicable to 1 of 158 methods.*
* [`CreateM2MTokenM2mResponseBody`](./src/Clerk/BackendAPI/Models/Errors/CreateM2MTokenM2mResponseBody.cs): 409 Conflict. Status code `409`. Applicable to 1 of 158 methods.*
* [`ResponseValidationError`](./src/Clerk/BackendAPI/Models/Errors/ResponseValidationError.cs): Thrown when the response data could not be deserialized into the expected type.
</details>

Expand Down Expand Up @@ -220,4 +225,150 @@ var res = await sdk.Miscellaneous.GetPublicInterstitialAsync(req);
```
<!-- End Server Selection [server] -->

<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client

The C# SDK makes API calls using an `ISpeakeasyHttpClient` that wraps the native
[HttpClient](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient). This
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
errors and response.

The `ISpeakeasyHttpClient` interface allows you to either use the default `SpeakeasyHttpClient` that comes with the SDK,
or provide your own custom implementation with customized configuration such as custom message handlers, timeouts,
connection pooling, and other HTTP client settings.

The following example shows how to create a custom HTTP client with request modification and error handling:

```csharp
using Clerk.BackendAPI;
using Clerk.BackendAPI.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _defaultClient;

public CustomHttpClient()
{
_defaultClient = new SpeakeasyHttpClient();
}

public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Add custom header and timeout
request.Headers.Add("x-custom-header", "custom value");
request.Headers.Add("x-request-timeout", "30");

try
{
var response = await _defaultClient.SendAsync(request, cancellationToken);
// Log successful response
Console.WriteLine($"Request successful: {response.StatusCode}");
return response;
}
catch (Exception error)
{
// Log error
Console.WriteLine($"Request failed: {error.Message}");
throw;
}
}

public void Dispose()
{
_httpClient?.Dispose();
_defaultClient?.Dispose();
}
}

// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new ClerkBackendApi(client: customHttpClient);
```

<details>
<summary>You can also provide a completely custom HTTP client with your own configuration:</summary>

```csharp
using Clerk.BackendAPI.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
private readonly HttpClient _httpClient;

public AdvancedHttpClient()
{
var handler = new HttpClientHandler()
{
MaxConnectionsPerServer = 10,
// ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
};

_httpClient = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
}

public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
}

public void Dispose()
{
_httpClient?.Dispose();
}
}

var sdk = ClerkBackendApi.Builder()
.WithClient(new AdvancedHttpClient())
.Build();
```
</details>

<details>
<summary>For simple debugging, you can enable request/response logging by implementing a custom client:</summary>

```csharp
public class LoggingHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _innerClient;

public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
{
_innerClient = innerClient ?? new SpeakeasyHttpClient();
}

public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Log request
Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");

var response = await _innerClient.SendAsync(request, cancellationToken);

// Log response
Console.WriteLine($"Received {response.StatusCode} response");

return response;
}

public void Dispose() => _innerClient?.Dispose();
}

var sdk = new ClerkBackendApi(client: new LoggingHttpClient());
```
</details>

The SDK also provides built-in hook support through the `SDKConfiguration.Hooks` system, which automatically handles
`BeforeRequestAsync`, `AfterSuccessAsync`, and `AfterErrorAsync` hooks for advanced request lifecycle management.
<!-- End Custom HTTP Client [http-client] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->
Loading