Descope 1.6.0
dotnet add package Descope --version 1.6.0
NuGet\Install-Package Descope -Version 1.6.0
<PackageReference Include="Descope" Version="1.6.0" />
<PackageVersion Include="Descope" Version="1.6.0" />
<PackageReference Include="Descope" />
paket add Descope --version 1.6.0
#r "nuget: Descope, 1.6.0"
#:package Descope@1.6.0
#addin nuget:?package=Descope&version=1.6.0
#tool nuget:?package=Descope&version=1.6.0
Descope .NET SDK
A .NET SDK for integrating with the Descope authentication and user management platform.
Installation
dotnet add package Descope
Client Configuration
Configure the Descope client using DescopeClientOptions:
var options = new DescopeClientOptions
{
ProjectId = "your-project-id", // Required
ManagementKey = "your-management-key", // Optional, for management APIs
AuthManagementKey = "your-auth-key", // Optional, for accessing disabled auth APIs
BaseUrl = "https://api.descope.com", // Optional, auto-detected from project ID
FgaCacheUrl = "https://fga.example.com", // Optional, if using the Descope FGA Cache Docker Container
IsUnsafe = false // Optional, for dev/test only
};
Creating the Client
Using Dependency Injection (Recommended)
services.AddDescopeClient(new DescopeClientOptions
{
ProjectId = "your-project-id",
ManagementKey = "your-management-key"
});
// Inject IDescopeClient in your services
public class MyService
{
private readonly IDescopeClient _client;
public MyService(IDescopeClient client)
{
_client = client;
}
}
Using Factory (Instance-based)
var client = DescopeManagementClientFactory.Create(new DescopeClientOptions
{
ProjectId = "your-project-id",
ManagementKey = "your-management-key"
});
Usage Examples
Authentication API Call
// Verify a magic link token
var response = await client.Auth.V1.Magiclink.Verify.PostAsync(
new VerifyMagicLinkRequest { Token = "magic-link-token" });
Management API V1 Call
// Create a test user
var user = await client.Mgmt.V1.User.Create.Test.PostAsync(
new CreateUserRequest
{
Identifier = "user@example.com",
Email = "user@example.com",
VerifiedEmail = true
});
Management API V2 Call
// Search users
var searchResponse = await client.Mgmt.V2.User.Search.PostAsync(
new SearchUsersRequest { Limit = 10 });
Management Flows
Management flows allow you to run server-side flows with custom input and receive dynamic output. The SDK provides a convenient extension method that deserializes the output as JSON for easy access.
// Run a management flow with custom input
var request = new RunManagementFlowRequest
{
FlowId = "my-management-flow",
Options = new ManagementFlowOptions
{
Input = new ManagementFlowOptions_input
{
AdditionalData = new Dictionary<string, object>
{
{ "email", "user@example.com" },
{ "customParam", "customValue" }
}
}
}
};
var response = await client.Mgmt.V1.Flow.Run.PostWithJsonOutputAsync(request);
// Access JSON properties directly using JsonElement
var root = response.OutputJson!.Value;
var email = root.GetProperty("email").GetString();
// Access nested objects using standard JsonElement methods
var greeting = root.GetProperty("obj").GetProperty("greeting").GetString();
var count = root.GetProperty("obj").GetProperty("count").GetInt32();
var enabled = root.GetProperty("obj").GetProperty("enabled").GetBoolean();
Token Validation
The SDK provides three methods for working with session tokens:
ValidateSessionAsync
Validates a session JWT locally using cached public keys. The public key is fetched from the server only once and then cached for subsequent validations.
var token = await client.Auth.ValidateSessionAsync(sessionJwt);
// Returns Token with claims, subject, expiration, etc.
RefreshSessionAsync
Refreshes an expired session using a refresh JWT. This method makes a remote API call to generate a new session token.
var newToken = await client.Auth.RefreshSessionAsync(refreshJwt);
// Returns a new session Token with updated expiration
ValidateAndRefreshSession
Attempts to validate the session JWT first (locally), and if that fails or the session is empty, falls back to refreshing using the refresh JWT (remote call).
var token = await client.Auth.ValidateAndRefreshSession(sessionJwt, refreshJwt);
// Returns valid Token, using local validation when possible
Performance Note: Validation calls (ValidateSessionAsync, ValidateAndRefreshSession) are highly efficient as they use locally cached public keys. Only RefreshSessionAsync and the refresh fallback in ValidateAndRefreshSession make remote API calls.
Authenticated User Operations
Some authentication operations require an authenticated user context and must be called with a refresh JWT. For these operations, use the PostWithJwt extension methods that explicitly require the refresh token.
Example: Update User Email
// Update user email using magic link (requires refresh JWT)
var response = await client.Auth.V1.Magiclink.Update.Email.PostWithJwtAsync(
new UpdateUserEmailMagicLinkRequest
{
Email = "newemail@example.com",
RedirectUrl = "https://myapp.com/verify"
},
refreshJwt);
Other operations requiring PostWithJwt include, among others: updating phone numbers, passwords, TOTP settings, WebAuthn devices, and getting user details via the /me endpoint.
ASP.NET OIDC Integration
For ASP.NET Core applications, use the AddDescopeOidcAuthentication extension method to integrate Descope as your Identity Provider (IdP) using OpenID Connect (OIDC):
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddDescopeOidcAuthentication(options =>
{
options.ProjectId = "your-project-id";
});
See the OIDC Demo Application for a complete working example with additional customization options.
For Maintainers
If you're maintaining or contributing to this SDK, see the Maintainer Guide for detailed information about code generation, extension methods, testing, and development workflows.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Kiota.Bundle (>= 1.21.3)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 112.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
-
net10.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 10.0.3)
- Microsoft.Kiota.Bundle (>= 1.21.3)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 112.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
-
net6.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 6.0.36)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.16.0)
- Microsoft.Kiota.Bundle (>= 1.21.3)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 112.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
-
net8.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 8.0.24)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.16.0)
- Microsoft.Kiota.Bundle (>= 1.21.3)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 112.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
-
net9.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 9.0.13)
- Microsoft.Kiota.Bundle (>= 1.21.3)
- Newtonsoft.Json (>= 13.0.4)
- RestSharp (>= 112.1.0)
- System.IdentityModel.Tokens.Jwt (>= 8.16.0)
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.6.0 | 330 | 3/23/2026 |
| 1.5.1 | 304 | 3/16/2026 |
| 1.5.0 | 600 | 2/26/2026 |
| 1.4.0 | 148 | 2/25/2026 |
| 1.3.4 | 183 | 2/20/2026 |
| 1.3.3 | 661 | 2/8/2026 |
| 1.3.2 | 102 | 2/5/2026 |
| 1.3.1 | 94 | 2/5/2026 |
| 1.3.0 | 1,401 | 1/18/2026 |
| 1.2.0 | 140 | 12/30/2025 |
| 1.1.0 | 114 | 12/29/2025 |
| 1.0.1 | 2,004 | 12/16/2025 |
| 1.0.0 | 275 | 12/14/2025 |
| 0.6.99 | 339 | 12/16/2025 |
| 0.6.9 | 336 | 12/12/2025 |
| 0.6.8 | 527 | 12/8/2025 |
| 0.6.7 | 491 | 11/27/2025 |
| 0.6.6 | 203 | 11/25/2025 |
| 0.6.5 | 269 | 11/16/2025 |
| 0.6.4 | 442 | 11/12/2025 |