AuthClient 1.5.4
dotnet add package AuthClient --version 1.5.4
NuGet\Install-Package AuthClient -Version 1.5.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="AuthClient" Version="1.5.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AuthClient" Version="1.5.4" />
<PackageReference Include="AuthClient" />
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.5.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AuthClient, 1.5.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 AuthClient@1.5.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=AuthClient&version=1.5.4
#tool nuget:?package=AuthClient&version=1.5.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AuthClient
A lightweight .NET authentication SDK for working with an auth API.
AuthClient provides simple async methods for modern authentication workflows:
- user registration
- login (with optional MFA/TOTP)
- logout
- get current user
- delete user
- admin user management
- OpenID Connect (OIDC)
- multi-factor authentication (MFA)
- password reset
- mail service configuration
Built by Brume Ako.
Features
- Simple, clean API
- Async-first design
- Token-based authentication
- OIDC provider support
- MFA (TOTP + QR setup)
- Password reset flows
- Mail service configuration (admin)
- Easy integration with any .NET app
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}
- POST /oidc/register
- DELETE /oidc/remove
- GET /oidc/login-url/{provider}
- POST /mfa/setup
- POST /mfa/verify
- DELETE /mfa/disable
- POST /auth/reset-request
- POST /auth/password-reset
- POST /modify-mail
- DELETE /remove-mail
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.LoginMfaAsync(
"user_id",
"123456"
);
Login with refresh token
var result = await client.LoginRefreshTokenAsync(
"refresh-token"
);
get refresh token
var result = await client.GetRefreshTokenAsync(
"your-jwt-token"
);
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");
Check Email Exists in db
await client.CheckEmail("email")
Get all users (admin)
var users = await client.GetAllUsersAsync("admin-token");
Delete user (admin)
await client.AdminDeleteUserAsync("admin-token", "user-id");
OpenID Connect (OIDC)
Register provider (admin)
await client.RegisterOidcProviderAsync(
"admin-key",
"google",
"client-id",
"client-secret",
"https://accounts.google.com/.well-known/openid-configuration"
);
Remove provider (admin)
await client.RemoveOidcProvider("admin-key", "google");
Get login URL
var url = await client.LoginWithOidc("google");
Open the returned URL in a browser to authenticate.
Multi-Factor Authentication (MFA)
Setup MFA (QR Code)
byte[] qrCode = await client.SetupMfa("your-jwt-token");
File.WriteAllBytes("qrcode.png", qrCode);
Verify MFA
await client.VerifyMfa("your-jwt-token", "123456");
Disable MFA
await client.DisableMfa("your-jwt-token", "123456");
Password Reset
Request reset
await client.RequestPasswordReset("user@example.com");
Reset password
await client.ResetPassword(
"user@example.com",
"NewPassword123",
"reset-code"
);
Mail Service (Admin)
Configure mail
await client.ModifyMailService(
"admin-key",
"sender",
"sendgrid-api-key"
);
Remove mail service
await client.DeleteMailServiceAsync("admin-token");
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
- OIDC providers are registered at runtime
- MFA setup returns a QR code image (PNG)
- 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 | Versions 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.