MicroOAuthServer 1.0.4

dotnet add package MicroOAuthServer --version 1.0.4
                    
NuGet\Install-Package MicroOAuthServer -Version 1.0.4
                    
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="MicroOAuthServer" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MicroOAuthServer" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="MicroOAuthServer" />
                    
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 MicroOAuthServer --version 1.0.4
                    
#r "nuget: MicroOAuthServer, 1.0.4"
                    
#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 MicroOAuthServer@1.0.4
                    
#: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=MicroOAuthServer&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=MicroOAuthServer&version=1.0.4
                    
Install as a Cake Tool

MicroOAuthServer

A minimal OAuth 2.1 authorization server for .NET. The main usage is to to secure MCP (Model Context Protocol) servers with standards-compliant OAuth flows.

See MCP protocol specification for details about authorization requirements.

Features

  • 🔐 OAuth 2.1 Compliant - PKCE-only flow (S256 method). Only Authorization Code and Refresh Token flows are supported.
  • 📋 Additional Standards Support:

Quick Start

1. Install the NuGet package

Using .NET CLI

dotnet add package MicroOAuthServer --version 0.0.2

or using Package Manager

Install-Package MicroOAuthServer -Version 0.0.2

2. Registed dependencies in your ASP.NET project's Program.cs

using MicroOAuthServer;
using MicroOAuthServer.WebApp.Data;
using MicroOAuthServer.WebApp.Services;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;

var builder = WebApplication.CreateBuilder(args);

...

builder.Services.AddMicroOAuthServer(options =>
    {
        options.JwtSigningKey = "ThisIsTotallyNotMyJWTSecretPleaseDontHackMe!";
        options.Issuer = "https://localhost:7194";
    })
    .UseEntityFrameworkCore(options => 
    { 
      options.UseDbContext<ApplicationDbContext>(); 
    })
    .AddUserStore<DemoUserStore>()
    .WithDynamicClientRegistration()
    .WithAuthorizationServerMetadata()
    .WithResourceServerMetadata();
...

// Configure default for JWT authentication ommited

...

var app = builder.Build();

...

app.UseMicroOAuthServer()            // /oauth/authorize and /oauth/token
   .UseDynamicClientRegistration()   // /oauth/register
   .UseAuthorizationServerMetadata() // /.well-known/oauth-authorization-server
   .UseResourceServerMetadata();     // /.well-known/auth-protected-resource

...

app.Run();

3. Register tables in the DbContext

// Your DbContext
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext
{
    // Your application entities (User, etc.)
    public DbSet<User> Users { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        // Configure MicroOAuthServer entities
        modelBuilder.ConfigureMicroOAuthServer();
    }
}

4. Implement reqired parts

Required (Implement Your Own):

  • IUserStore - Authenticate users against your database
  • Consent screen for you appp on /oauth/authorize. See examples.

Optional (Customize as Needed):

  • IAuthorizationHandler
  • ITokenHandler
  • IClientStore, IAuthorizationCodeStore, IRefreshTokenStore

Register a custom implementation of the insterfaces after .AddMicroOAuthServer() call to replace built-in.

Example

1. Build and run


cd ./examples/MicroOAuthServer.WebAppWithMCP/
dotnet run

Or if you have .NET Aspire


cd ./examples/
aspire run

Aspire will automatically setup a Docker container with MS SQL database.

2. Test

Use MCP Inspecector to explore MCP tools in the example application. It has all OAuth-related functionality build-in, including support for dynamic client registration.

Product Compatible and additional computed target framework versions.
.NET 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. 
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.0.4 114 1/11/2026
1.0.3 101 1/8/2026
1.0.2 99 1/6/2026
1.0.1 96 1/6/2026
0.0.2 99 1/6/2026
0.0.1 101 1/4/2026