MaksIT.IdentityHub.Client 4.1.0

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

MaksIT.IdentityHub.Client

NuGet License: MIT Line Coverage Branch Coverage Method Coverage

NuGet client for MAKS-IT Identity Hub.

Hub controllers use result.ToActionResult(); this client maps HTTP with Result.FromHttpResponseAsync / Result{T}.FromHttpResponseAsync.

Surfaces

Interface Use when Auth
IIdentityHubIdpClient Covered apps, Google/Microsoft challenge/redeem, mailbox Anonymous + external Hub JWT for mailbox only
IIdentityHubAdminClient Admin login, users, audit, debug/sidecar AdminAccessToken (global admin for most)
IIdentityHubClient Both Combines the two

SignalR /hubs/sidecar-status is WebUI-only (not wrapped).

Token names (do not mix)

Name What it is Where
AdminAccessToken Hub JWT for admin Default Bearer for admin APIs; set by LoginAsync / RefreshTokenAsync
ExternalLoginAccessToken Hub JWT for external from IdP redeem Mailbox Bearer only; set by RedeemLoginExternalAsync
MailboxAccessTokenResponse.IdpAccessToken IdP mailbox access token Response body - not a Hub JWT

IdP challenge/redeem never set AdminAccessToken.

Install

dotnet add package MaksIT.IdentityHub.Client

DI

IdP-only (PostClient mailbox or Google/Microsoft product login - no Hub admin login):

services.AddIdentityHubIdpClient("https://identity.maks-it.com");
// inject IIdentityHubIdpClient

Full API (admin + IdP):

services.AddIdentityHubClient(opts => {
  opts.BaseAddress = "https://identity.maks-it.com";
});
// inject IIdentityHubClient, or IIdentityHubIdpClient / IIdentityHubAdminClient

Covered applications

GET login-external/covered-applications returns { id, name } entries (CoveredApplicationInfo): technical Id and commercial Name from Hub config. Official desktop apps open Hub /desktop-login?provider=Google|Microsoft&app={Id} for a personalized confirm (Name) before challenge; this library builds the challenge URL directly and does not open /desktop-login. Privacy/Terms on Hub list every covered app from that endpoint.

Browser challenge and redemption

Use an HTTPS Hub base address. The signing-in browser must visit the Hub challenge itself so the callback carries the Hub cookies. For direct HTTP flows, GetLoginExternalChallengeAsync accepts app and optional loginHint. Its PowerShell equivalent accepts -App and -LoginHint. With a configured covered list, Hub requires an exact application ID. The hint only preselects an account.

sequenceDiagram
  participant B as User browser
  participant C as Desktop app or SPA WebAPI
  participant H as Identity Hub
  participant I as Google or Entra
  C-->>B: Hub challenge URL with app and S256 challenge
  B->>H: Navigate to challenge
  H-->>B: Set cookies and redirect to IdP
  B->>I: Sign in
  I-->>B: Redirect to Hub with opaque state
  B->>H: Callback with Hub cookies
  H-->>B: Redirect to allowed postLogin with OTC
  B->>C: Return OTC to initiating session
  C->>H: Redeem OTC and verifier
  H-->>C: External session

Opaque state is internal to the Hub. Bind the verifier to one login attempt. Desktop hosts keep it in memory or in the initiating Hub tab for the hosted desktop flow. WebAPI hosts keep it in the user's server-side session. Redact OTCs, verifiers and JWTs from logs. A copied OTC requires its verifier and expires after the Hub's short redemption window.

Examples (IdP only - no Hub admin login)

Register once with AddIdentityHubIdpClient, inject IIdentityHubIdpClient. Generate a PKCE code_verifier / S256 code_challenge in the app. postLogin must be an HTTPS host listed in Hub AllowedPostLoginHosts.

Sign-in with Google or Microsoft

Use when the app only needs a Hub session for an external user (no mailbox / IMAP). Omit mailboxPurpose (default false) so Hub requests only openid email profile.

// WebAPI redirects the user's browser to this URL and retains the verifier in the session.
var path = IdentityHubClient.BuildLoginExternalChallengePath(
  provider: "Google", postLogin: "https://app.maks-it.com/callback",
  codeChallenge: codeChallenge, app: "MaksIT.ReactRedux", loginHint: email);
var challengeUrl = new Uri(new Uri("https://identity.maks-it.com/"), path);

// After IdP redirects to Hub callback, Hub redirects to postLogin?code=<otc>
// 3) Redeem OTC + PKCE verifier -> Hub JWT for the external principal
var redeem = await idp.RedeemLoginExternalAsync(otcCode, codeVerifier);
if (!redeem.IsSuccess)
  throw new InvalidOperationException(string.Join("; ", redeem.Messages));

var hubJwt = redeem.Value!.ExternalLoginAccessToken;
// Use hubJwt as Bearer against your own APIs / covered product - not for Hub admin APIs.
// Do not call LoginAsync; AdminAccessToken stays unset.

PostClient - mailbox access (XOAUTH2)

Use when PostClient needs a Google/Microsoft mailbox access token via Hub. Pass mailboxPurpose: true so Hub requests configured mailbox scopes and can vault a refresh token.

// Desktop opens this Hub URL in the system browser.
var path = IdentityHubClient.BuildLoginExternalChallengePath(
  provider: "Google", postLogin: "https://postclient.maks-it.com/desktop-callback",
  codeChallenge: codeChallenge, app: "MaksIT.PostClient", mailboxPurpose: true);
var challengeUrl = new Uri(new Uri("https://identity.maks-it.com/"), path);

// User completes IdP; Hub OTC arrives on postLogin
var redeem = await idp.RedeemLoginExternalAsync(otcCode, codeVerifier);
if (!redeem.IsSuccess)
  throw new InvalidOperationException(string.Join("; ", redeem.Messages));
// idp.ExternalLoginAccessToken is set from redeem

// 3) Exchange external Hub JWT for IdP mailbox token (IMAP/POP/SMTP XOAUTH2)
var mailbox = await idp.GetMailboxAccessTokenAsync();
if (!mailbox.IsSuccess)
  throw new InvalidOperationException(string.Join("; ", mailbox.Messages));

var idpMailboxToken = mailbox.Value!.IdpAccessToken;
// Use idpMailboxToken with the IdP mail server - never treat it as a Hub JWT.

Later mailbox renewal (Hub stays transparent - IdP refresh is vaulted on Hub):

// If the Hub external session expired, renew it (anonymous IdP surface - not admin refresh)
var session = await idp.RefreshLoginExternalAsync(storedHubRefreshToken);
if (!session.IsSuccess)
  throw new InvalidOperationException(string.Join("; ", session.Messages));
// session.Value.ExternalLoginAccessToken is set on idp as well

var mailbox = await idp.GetMailboxAccessTokenAsync();
// or: GetMailboxAccessTokenAsync(externalLoginAccessToken: session.Value!.ExternalLoginAccessToken);

While the Hub external session is still valid, call GetMailboxAccessTokenAsync alone - Hub refreshes the IdP mailbox token from its vault.

Admin (optional)

Only when the app manages Hub users / audit (WebUI-style). Not needed for PostClient or Google/Microsoft product login.

services.AddIdentityHubClient("https://identity.maks-it.com");

IIdentityHubAdminClient admin = ...;
var login = await admin.LoginAsync(new LoginRequest { Username = "admin", Password = "..." });
var users = await admin.SearchUsersAsync(new SearchUserRequest { PageNumber = 1, PageSize = 25 });
await admin.LogoutAsync(new LogoutRequest());

PowerShell

See MaksIT.IdentityHub.Client.PowerShell. Connect-IdentityHub -BaseAddress <url> without -AdminAccessToken for IdP-only; optional -ExternalLoginAccessToken for mailbox.

E2E (manual)

PowerShell scenarios against a running Hub (Compose from maksit-identity-hub): src/e2e-tests/README.md. Not run in CI.

pwsh -File .\src\e2e-tests\Test-IdentityHubE2E.ps1

Contributing

See CONTRIBUTING.md and homelab works/repostories-maintenance/nuget-trusted-publishing.md.

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
4.1.0 49 11/19/2026
4.0.0 99 11/3/2026
3.1.3 111 10/28/2026
3.1.2 98 10/28/2026
3.1.1 102 10/28/2026
3.0.0 107 10/27/2026
2.2.0 108 9/24/2026
2.1.2 121 9/20/2026
2.1.1 116 9/19/2026
2.1.0 133 9/18/2026
2.0.1 147 9/17/2026
2.0.0 115 9/17/2026
1.6.0 119 9/16/2026
1.5.1 142 8/21/2026
1.5.0 173 8/18/2026
1.4.3 133 8/16/2026
1.4.1 133 8/12/2026
1.4.0 137 8/1/2026
1.3.0 132 7/30/2026
1.1.0 141 7/27/2026