AuthClient 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AuthClient --version 1.0.0
                    
NuGet\Install-Package AuthClient -Version 1.0.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="AuthClient" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AuthClient" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AuthClient" />
                    
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 AuthClient --version 1.0.0
                    
#r "nuget: AuthClient, 1.0.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 AuthClient@1.0.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=AuthClient&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AuthClient&version=1.0.0
                    
Install as a Cake Tool

AuthClient

A lightweight .NET authentication SDK for working with an auth API.

AuthClient provides simple async methods for common authentication workflows:

  • user registration
  • login (with optional MFA/TOTP)
  • logout
  • get current user
  • delete user
  • admin user management

Built by Brume Ako.


Features

  • Simple, clean API
  • Async-first design
  • Token-based authentication
  • Easy integration with any .NET app
  • Includes admin endpoints

Installation

dotnet add package AuthClient

Requirements

  • .NET 6.0 or later

  • A backend API with endpoints:

    • POST /register
    • POST /login
    • POST /logout
    • GET /me
    • DELETE /delete
    • GET /admin/users
    • DELETE /admin/delete-user/{user_id}

Getting Started

Create the client

using AuthClient;

var client = new AuthClient.AuthClient("https://your-api-url.com");

Usage

Register

var result = await client.RegisterAsync(
    "user@example.com",
    "StrongPassword123",
    "John Doe"
);

Login

var result = await client.LoginAsync(
    "user@example.com",
    "StrongPassword123"
);

Login with MFA

var result = await client.LoginAsync(
    "user@example.com",
    "StrongPassword123",
    "123456"
);

Logout

await client.LogoutAsync("your-jwt-token");

Get current user

var user = await client.GetUserAsync("your-jwt-token");

Delete current user

await client.DeleteUserAsync("your-jwt-token");

Get all users (admin)

var users = await client.GetAllUsersAsync("admin-token", default);

Delete user (admin)

await client.AdminDeleteUserAsync("admin-token", "user-id");

Error Handling

All requests use EnsureSuccessStatusCode().

Wrap calls in try/catch:

try
{
    await client.LoginAsync("user@example.com", "password");
}
catch (HttpRequestException ex)
{
    Console.WriteLine(ex.Message);
}

Notes

  • Responses are returned as JsonElement
  • Tokens must be passed manually
  • Designed to be minimal and flexible

Project Structure

AuthClient/
├── AuthClient/   # SDK (published to NuGet)
└── TestApp/      # Example app (not published)

License

MIT License


Author

Brume Ako

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.
  • net10.0

    • No dependencies.

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.5.4 196 3/26/2026
1.5.3 106 3/26/2026
1.5.2 108 3/26/2026
1.5.1 108 3/26/2026
1.5.0 106 3/26/2026
1.4.1 108 3/26/2026
1.4.0 107 3/26/2026
1.3.1 106 3/26/2026
1.3.0 128 3/26/2026
1.2.1 117 3/24/2026
1.2.0 121 3/24/2026
1.1.0 163 3/24/2026
1.0.0 138 3/24/2026