Svrooij.Identity.Client.Extensions
0.1.0
dotnet add package Svrooij.Identity.Client.Extensions --version 0.1.0
NuGet\Install-Package Svrooij.Identity.Client.Extensions -Version 0.1.0
<PackageReference Include="Svrooij.Identity.Client.Extensions" Version="0.1.0" />
<PackageVersion Include="Svrooij.Identity.Client.Extensions" Version="0.1.0" />
<PackageReference Include="Svrooij.Identity.Client.Extensions" />
paket add Svrooij.Identity.Client.Extensions --version 0.1.0
#r "nuget: Svrooij.Identity.Client.Extensions, 0.1.0"
#:package Svrooij.Identity.Client.Extensions@0.1.0
#addin nuget:?package=Svrooij.Identity.Client.Extensions&version=0.1.0
#tool nuget:?package=Svrooij.Identity.Client.Extensions&version=0.1.0
Extensions for Microsoft.Identity.Client
The Microsoft Authentication Library (MSAL) is great for getting tokens, but it does not provide a way to use managed identities in your Confidential Client applications.
This library provides extensions on top of the ConfidentialClientApplicationBuilder to allow using managed identities instead of client secrets or certificates.
Installation
You can install the package via NuGet:
dotnet add package Svrooij.Identity.Client.Extensions
Usage
WithTokenCredential
You can use the WithTokenCredential extension method to configure your ConfidentialClientApplication to use a managed identity.
using Azure.Identity;
using Microsoft.Identity.Client;
using Svrooij.Identity.Client.Extensions;
var tokenCredential = new ManagedIdentityCredential();
var app = ConfidentialClientApplicationBuilder
.Create("your-client-id")
.WithTenantId("your-tenant-id")
.WithTokenCredential(tokenCredential) // Add this instead of WithClientSecret or WithCertificate
.Build();
// Use client credentials flow to get a token
var result = await app.AcquireTokenForClient(new[] { "https://graph.microsoft.com/.default" }).ExecuteAsync();
// Use on-behalf-of flow to get a token
var userAssertion = new UserAssertion("user-access-token");
var oboResult = await app.AcquireTokenOnBehalfOf(new[] { "https://graph.microsoft.com/user.read" }, userAssertion).ExecuteAsync();
Why another library?
The code for this method is rather simple, but is seems like nobody is using this approach yet. I don't care much about if you use this library or copy this one method into your own codebase, as long as you stop using client secrets in your applications.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Azure.Core (>= 1.49.0)
- Microsoft.Identity.Client (>= 4.77.1)
-
net9.0
- Azure.Core (>= 1.49.0)
- Microsoft.Identity.Client (>= 4.77.1)
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 | 179 | 10/10/2025 |