Skip to main content
net10.0net8.0net9.0

An Aspire client integration for Logto that registers OpenID Connect (OIDC) or JWT authentication services in the dependency injection container.

Published
Sep 12, 2026
1mo ago
Total Downloads
2.3K
2,281

Install

dotnet add package CommunityToolkit.Aspire.Logto.Client --version 13.5.1-beta.751
ProductVersions
.NET
net10.0net8.0net9.0

README

CommunityToolkit.Aspire.Logto.Client

Registers Logto authentication services in the DI container for connecting to a Logto instance using OpenID Connect or JWT Bearer authentication.

Getting started

Prerequisites

  • A Logto instance (can be hosted via CommunityToolkit.Aspire.Hosting.Logto).

Install the package

Install the Aspire Logto Client library with NuGet:

dotnet add package CommunityToolkit.Aspire.Logto.Client

Usage example

OpenID Connect (OIDC) Authentication

In the Program.cs file of your project, call the AddLogtoOIDC extension method to register Logto OIDC authentication for use via the dependency injection container. The method takes an optional connection name parameter.

builder.AddLogtoOIDC("logto");

JWT Bearer Authentication

For API projects that need to validate Logto-issued JWTs, use the AddLogtoJwtBearer extension method on the AuthenticationBuilder:

builder.Services
    .AddAuthentication()
    .AddLogtoJwtBearer("logto", "your-app-identifier");

Configuration

The Aspire Logto Client integration provides multiple options to configure the server connection based on the requirements and conventions of your project.

Use a connection string

When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string when calling builder.AddLogtoOIDC():

builder.AddLogtoOIDC("logto");

And then the connection string will be retrieved from the ConnectionStrings configuration section:

{
    "ConnectionStrings": {
        "logto": "Endpoint=http://localhost:3001"
    }
}

Use configuration providers

The Aspire Logto Client integration supports Microsoft.Extensions.Configuration. It loads the settings from configuration by using the Aspire:Logto:Client key. Example appsettings.json that configures some of the options:

{
  "Aspire": {
    "Logto": {
      "Client": {
        "Endpoint": "http://localhost:3001",
        "AppId": "your-app-id",
        "AppSecret": "your-app-secret"
      }
    }
  }
}

Use inline delegates

You can also pass the Action<LogtoOptions> delegate to set up some or all the options inline, for example to set the AppId from code:

builder.AddLogtoOIDC("logto", logtoOptions: options =>
{
    options.AppId = "your-app-id";
    options.AppSecret = "your-app-secret";
});

AppHost extensions

In your AppHost project, install the CommunityToolkit.Aspire.Hosting.Logto library with NuGet:

dotnet add package CommunityToolkit.Aspire.Hosting.Logto

Then, in the Program.cs file of AppHost, register a Logto instance and consume the connection using the following methods:

var postgres = builder.AddPostgres("postgres");

var logto = builder.AddLogto("logto", postgres);

var myService = builder.AddProject<Projects.MyService>()
                       .WithReference(logto);

The WithReference method configures a connection in the MyService project named logto. In the Program.cs file of MyService, the Logto connection can be consumed using:

builder.AddLogtoOIDC("logto");

Additional documentation

Feedback & contributing

https://github.com/CommunityToolkit/Aspire

Changes from Previous Version

No structural changes between v13.5.1-beta.748 and v13.5.1-beta.751.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.