Rystem.RepositoryFramework.Api.Client.Authentication.BlazorWasm 10.0.7

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

What is Rystem?

Rystem.RepositoryFramework.Api.Client.Authentication.BlazorWasm

NuGet NuGet Downloads

Blazor WebAssembly authentication helpers for Rystem.RepositoryFramework.Api.Client.

This package plugs a WASM-friendly token manager based on IAccessTokenProvider into the repository API client's interceptor pipeline.

Resources


Installation

dotnet add package Rystem.RepositoryFramework.Api.Client.Authentication.BlazorWasm

The current package metadata in src/Repository/RepositoryFramework.Api.Client.Authentication.BlazorWasm/RepositoryFramework.Api.Client.Authentication.BlazorWasm.csproj is:

  • package id: Rystem.RepositoryFramework.Api.Client.Authentication.BlazorWasm
  • version: 10.0.6
  • target framework: net10.0
  • main auth dependency: Microsoft.AspNetCore.Components.WebAssembly.Authentication 10.0.3

Package architecture

Area Purpose
TokenManager Acquire and cache access tokens through IAccessTokenProvider
Convenience extensions Register the token manager in the base repository API-client interceptor pipeline
Shared AuthenticatorSettings Carry scopes and optional exception handling settings

Mental model

Like the Blazor Server package, this package does not replace the repository API client. It only supplies a WASM-specific token source.

All HTTP behavior still comes from Rystem.RepositoryFramework.Api.Client:

  • repository methods map to the same server routes
  • request interceptors enrich the outgoing client
  • response interceptors can react to non-success responses

This package only handles token acquisition in the browser-hosted auth model.


Typical setup

builder.Services.AddOidcAuthentication(options =>
{
    builder.Configuration.Bind("OidcProvider", options.ProviderOptions);
    options.ProviderOptions.DefaultScopes.Add("api.access");
});

builder.Services.AddDefaultAuthorizationInterceptorForApiHttpClient(settings =>
{
    settings.Scopes = ["api.access"];
});

builder.Services.AddRepository<Product, int>(repositoryBuilder =>
{
    repositoryBuilder.WithApiClient(apiBuilder =>
    {
        apiBuilder.WithHttpClient("https://api.example.com");
    });
});

Extension methods

All convenience methods are registered on IServiceCollection.

Method Scope
AddDefaultAuthorizationInterceptorForApiHttpClient(settings?) all repository clients
AddDefaultAuthorizationInterceptorForApiHttpClient<T>(settings?) one model
AddDefaultAuthorizationInterceptorForApiHttpClient<T, TKey>(settings?) one model + key

These are just WASM-friendly wrappers over the generic bearer-registration helpers from Rystem.RepositoryFramework.Api.Client.


How TokenManager works

The token manager keeps a cached AccessToken and refreshes it when needed.

Token lifecycle

  1. If there is no cached token, request a new one.
  2. If the cached token expires within the next 5 minutes, request a new one.
  3. If the cached token is still valid, reuse it.
  4. When a token is available, set Authorization: Bearer {token} on the outgoing HttpClient.

Scopes

  • when AuthenticatorSettings.Scopes is present, it calls RequestAccessToken(new AccessTokenRequestOptions { Scopes = ... })
  • when scopes are missing, it calls the parameterless RequestAccessToken() overload

AuthenticatorSettings

This package reuses the shared settings model from the core API client package.

public class AuthenticatorSettings
{
    public string[]? Scopes { get; set; }
    public Func<Exception, IServiceProvider, Task>? ExceptionHandler { get; set; }
}
  • Scopes directly affects the IAccessTokenProvider request
  • ExceptionHandler is executed by the base bearer interceptor when token enrichment throws

Source-backed behavior notes

Client-side token cache

The token manager stores the last successful AccessToken instance and reuses it until the token is within 5 minutes of expiry.

Exception behavior

If token acquisition throws, the base bearer interceptor catches the exception and can call ExceptionHandler if configured.

No-token result nuance

If IAccessTokenProvider.RequestAccessToken() completes without a usable token, the current implementation returns string.Empty rather than null.

That means the base bearer interceptor can still set an empty bearer header on that path. The happy path is solid, but this edge case is less polished than the Blazor Server variant.

Inherited interceptor caveat

Because these helpers use the base API-client registration pipeline:

  • global and model-specific registrations add both request and response interceptors
  • model-plus-key registration currently adds only the request interceptor

So automatic 401 refresh-and-retry is available for the global and model-specific paths, but not fully for the model-plus-key path.


Practical examples

Global registration

builder.Services.AddDefaultAuthorizationInterceptorForApiHttpClient(settings =>
{
    settings.Scopes = ["api://your-api-id/.default", "api.read"];
});

Model-specific registration

builder.Services.AddDefaultAuthorizationInterceptorForApiHttpClient<Product>(settings =>
{
    settings.Scopes = ["api://your-api-id/.default"];
});

Model-and-key-specific registration

builder.Services.AddDefaultAuthorizationInterceptorForApiHttpClient<Product, int>(settings =>
{
    settings.Scopes = ["api://your-api-id/.default"];
});

Package Purpose
Rystem.RepositoryFramework.Api.Client Base repository HTTP client and interceptor pipeline
Rystem.RepositoryFramework.Api.Client.Authentication.BlazorServer Equivalent auth helpers for Blazor Server
Rystem.RepositoryFramework.Api.Server Matching server package

Read this package after src/Repository/RepositoryFramework.Api.Client/README.md when your repository client runs in Blazor WebAssembly.

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
10.0.7 0 3/26/2026
10.0.6 135,781 3/3/2026
10.0.5 97 2/22/2026
10.0.4 100 2/9/2026
10.0.3 147,875 1/28/2026
10.0.1 209,059 11/12/2025
9.1.3 241 9/2/2025
9.1.2 764,453 5/29/2025
9.1.1 97,803 5/2/2025
9.0.32 186,714 4/15/2025
9.0.31 5,776 4/2/2025
9.0.30 88,808 3/26/2025
9.0.29 9,009 3/18/2025
9.0.28 259 3/17/2025
9.0.27 237 3/16/2025
9.0.26 259 3/13/2025
9.0.25 52,108 3/9/2025
9.0.21 333 3/6/2025
9.0.20 19,568 3/6/2025
9.0.19 353 3/6/2025
Loading failed