Xylocopadream.Otp.Client
0.1.0
Prefix Reserved
dotnet add package Xylocopadream.Otp.Client --version 0.1.0
NuGet\Install-Package Xylocopadream.Otp.Client -Version 0.1.0
<PackageReference Include="Xylocopadream.Otp.Client" Version="0.1.0" />
<PackageVersion Include="Xylocopadream.Otp.Client" Version="0.1.0" />
<PackageReference Include="Xylocopadream.Otp.Client" />
paket add Xylocopadream.Otp.Client --version 0.1.0
#r "nuget: Xylocopadream.Otp.Client, 0.1.0"
#:package Xylocopadream.Otp.Client@0.1.0
#addin nuget:?package=Xylocopadream.Otp.Client&version=0.1.0
#tool nuget:?package=Xylocopadream.Otp.Client&version=0.1.0
Xylocopadream.Otp.Client
Client for the Xylocopadream OTP server: passwordless login by e-mail code, secure token storage and automatic JWT refresh.
Usage
The client stores tokens through IEasySecureStorage, so register a platform implementation first (see Xylocopadream.EasySecureStorage.*).
builder.Services.AddEasySecureStorageMaui();
// audience: the service (API) the tokens are for, listed in the OTP server "JwtSettings:Audiences"
builder.Services.AddOtpModules(new Uri("https://otp.example.com/"), audience: "my-api");
public sealed class LoginViewModel(IAuthFacade auth)
{
public Task<Resu<RequestAccessResult>> SendCodeAsync(string email)
=> auth.RequestAccessAsync(email); // 1. the server e-mails a code
public Task<Resu> LoginAsync(string email, string code)
=> auth.LoginAsync(email, code); // 2. tokens are stored securely
public Task<Resu<RestoreSessionResult>> RestoreAsync()
=> auth.RestoreSessionAsync(); // on startup, uses the refresh token
}
The session is exposed read-only and bindable through IAuthenticationState. When the refresh token is rejected (expired or revoked), the session is cleared and SessionExpired is raised:
app.Services.GetRequiredService<IAuthenticationState>().SessionExpired += (_, _) =>
MainThread.BeginInvokeOnMainThread(() => navigator.NavigateTo<LoginPageIdentifier>());
To call your own APIs with the access token (refreshed automatically on expiry):
services.AddAuthenticatedHttpClient<MyApiClient>(new Uri("https://api.example.com/"));
License
GPL-3.0-or-later
| 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. |
-
net10.0
- CommunityToolkit.Mvvm (>= 8.4.2)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- System.IdentityModel.Tokens.Jwt (>= 8.19.2)
- Xylocopadream.EasyResu (>= 0.1.0)
- Xylocopadream.EasySecureStorage (>= 0.1.0)
- Xylocopadream.Otp.Authenticate.Contracts (>= 0.1.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 |
|---|---|---|
| 0.1.0 | 42 | 10/7/2026 |