NuvTools.Account.Client.Native 11.0.0

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

NuvTools.Account.Client.Native

Signing in through Nuv Tools Account from an application installed on a device, desktop or mobile: the authorization code flow with PKCE as a native client, through the system browser.

It depends on no UI framework. The application supplies two things: how the browser is opened (IAccountBrowser) and where the grants are kept (IAccountGrantStore).

What it does

  • Sends the person to the Account in the system browser and redeems the code that comes back, checking that the answer is at the registered address and is the answer to its own request.
  • Keeps one grant for each organization the person signs in to, so switching between them does not go back to the browser.
  • Hands out the current access token and renews it when it is about to expire, replacing the refresh token the Account rotates.
  • Lists the person's organizations (account-api scope) and signs out.

What to know before using it

The Account asks the person to confirm every sign-in of an installed application, on a page of its own: which application, as whom, for which organization. It never authorizes a native client silently, because any program on the device can claim to be it. So:

  • an organization is confirmed in the browser once per device, the first time it is chosen;
  • after that its grant is renewed without the browser;
  • there is no silent sign-in, and nothing here asks for one.

Open the system browser, never an embedded web view. In .NET MAUI, WebAuthenticator does it. Keep the grants in the operating system's protected storage. In .NET MAUI, SecureStorage. A refresh token is as good as the person's session until it is revoked.

Registration at the Account

The application is a native client, with addresses in a scheme of its own named after a domain in reverse:

{
  "ClientId": "apistudio-desktop",
  "DisplayName": "Nuv Tools API Studio",
  "Native": true,
  "RedirectUris": [ "com.nuvtools.apistudio:/callback" ],
  "PostLogoutRedirectUris": [ "com.nuvtools.apistudio:/signed-out" ],
  "Scopes": [ "apistudio-api", "account-api" ]
}

The same scheme is registered with the operating system by the application, so the browser's return reaches it.

Use

var options = new NuvToolsAccountNativeOptions
{
    Authority = "https://account.nuvtools.com/",
    ClientId = "apistudio-desktop",
    RedirectUri = "com.nuvtools.apistudio:/callback",
    PostLogoutRedirectUri = "com.nuvtools.apistudio:/signed-out"
};

options.Scopes.Add("apistudio-api");
options.Scopes.Add("account-api");

// One for the application's lifetime.
var signIn = new NuvToolsAccountNativeSignIn(new HttpClient(), options, browser, grantStore);

var result = await signIn.SignInAsync();                 // the browser, and the confirmation page
var organizations = await signIn.GetOrganizationsAsync();
await signIn.SwitchAsync(organizations.Data![0].OrganizationId);
var token = await signIn.GetAccessTokenAsync();          // renewed when needed
await signIn.SignOutAsync();

For the product's own API, NuvToolsAccountNativeBearerHandler puts the token on each request and renews it once when the API refuses it. Attach it only to the client that calls that API.

The browser, in .NET MAUI

public sealed class MauiAccountBrowser : IAccountBrowser
{
    public async Task<Uri?> NavigateAsync(Uri address, Uri callback, CancellationToken cancellationToken)
    {
        try
        {
            var result = await WebAuthenticator.Default.AuthenticateAsync(
                new WebAuthenticatorOptions { Url = address, CallbackUrl = callback }, cancellationToken);

            var query = string.Join('&', result.Properties.Select(e => $"{e.Key}={Uri.EscapeDataString(e.Value)}"));

            return new Uri($"{callback.AbsoluteUri}?{query}");
        }
        catch (TaskCanceledException)
        {
            return null;
        }
    }
}

The store, in .NET MAUI

public sealed class MauiGrantStore : IAccountGrantStore
{
    private const string Key = "nuvtools.account.grants";

    public Task<string?> ReadAsync(CancellationToken cancellationToken) => SecureStorage.Default.GetAsync(Key);

    public Task WriteAsync(string value, CancellationToken cancellationToken) => SecureStorage.Default.SetAsync(Key, value);

    public Task ClearAsync(CancellationToken cancellationToken)
    {
        SecureStorage.Default.Remove(Key);

        return Task.CompletedTask;
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.  net11.0 is compatible. 
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
11.0.0 70 12/2/2026