Azure.Identity.Broker
1.0.0-beta.5
Prefix Reserved
Versions 1.2.0-beta.1 and earlier rely on vulnerable versions of the Azure.Identity package.
See the version list below for details.
dotnet add package Azure.Identity.Broker --version 1.0.0-beta.5
NuGet\Install-Package Azure.Identity.Broker -Version 1.0.0-beta.5
<PackageReference Include="Azure.Identity.Broker" Version="1.0.0-beta.5" />
paket add Azure.Identity.Broker --version 1.0.0-beta.5
#r "nuget: Azure.Identity.Broker, 1.0.0-beta.5"
// Install Azure.Identity.Broker as a Cake Addin #addin nuget:?package=Azure.Identity.Broker&version=1.0.0-beta.5&prerelease // Install Azure.Identity.Broker as a Cake Tool #tool nuget:?package=Azure.Identity.Broker&version=1.0.0-beta.5&prerelease
Azure Identity Brokered Authentication client library for .NET
The library extends the Azure.Identity library to provide authentication broker support. It includes the necessary dependencies, and provides the InteractiveBrowserCredentialBrokerOptions
class. This options class can be used to create an InteractiveBrowserCredential
capable of using the system authentication broker in lieu of the system browser when available.
Source code | Package (nuget) | API reference documentation | Microsoft Entra ID documentation
Getting started
Install the package
Install the Azure Identity client library for .NET with NuGet:
dotnet add package Azure.Identity.Broker --prerelease
Prerequisites
- The Azure.Identity library is a dependency of Azure.Identity.Broker.
Authenticate the client
Key concepts
Examples
Configuring the InteractiveBrowserCredential
to use the system authentication broker
This example demonstrates configuring the InteractiveBrowserCredential
with the specialized options type InteractiveBrowserCredentialBrokerOptions
to enable brokered authentication.
IntPtr parentWindowHandle = GetForegroundWindow();
// Create an interactive browser credential which will use the system authentication broker
var credential = new InteractiveBrowserCredential(new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle));
// Use the credential to authenticate a secret client
var client = new SecretClient(new Uri("https://myvault.vault.azure.net/"), credential);
Troubleshooting
See the troubleshooting guide for details on how to diagnose various failure scenarios.
Error Handling
Errors arising from authentication can be raised on any service client method which makes a request to the service. This is because the first time the token is requested from the credential is on the first call to the service, and any subsequent calls might need to refresh the token. In order to distinguish these failures from failures in the service client Azure Identity classes raise the AuthenticationFailedException
with details to the source of the error in the exception message as well as possibly the error message. Depending on the application these errors may or may not be recoverable.
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
// Create a secret client using the DefaultAzureCredential
var client = new SecretClient(new Uri("https://myvault.vault.azure.net/"), new DefaultAzureCredential());
try
{
KeyVaultSecret secret = await client.GetSecretAsync("secret1");
}
catch (AuthenticationFailedException e)
{
Console.WriteLine($"Authentication Failed. {e.Message}");
}
For more details on dealing with errors arising from failed requests to Microsoft Entra ID, or managed identity endpoints please refer to the Microsoft Entra ID documentation on authorization error codes.
Logging
The Azure Identity library provides the same logging capabilities as the rest of the Azure SDK.
The simplest way to see the logs to help debug authentication issues is to enable the console logging.
// Setup a listener to monitor logged events.
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
All credentials can be configured with diagnostic options, in the same way as other clients in the SDK.
DefaultAzureCredentialOptions options = new DefaultAzureCredentialOptions()
{
Diagnostics =
{
LoggedHeaderNames = { "x-ms-request-id" },
LoggedQueryParameters = { "api-version" },
IsLoggingContentEnabled = true
}
};
CAUTION: Requests and responses in the Azure Identity library contain sensitive information. Precaution must be taken to protect logs when customizing the output to avoid compromising account security.
Thread safety
We guarantee that all credential instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing credential instances is always safe, even across threads.
Additional concepts
Client options | Accessing the response | Diagnostics | Mocking | Client lifetime
Next steps
Client libraries supporting authentication with Azure Identity
Many of the client libraries listed here support authenticating with TokenCredential
and the Azure Identity library.
There you will also find links where you can learn more about their use, including additional documentation and samples.
Known Issues
This library does not currently support scenarios relating to the AAD B2C service.
Currently open issues for the Azure.Identity library can be found here.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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. |
.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 is compatible. 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. |
-
.NETFramework 4.6.2
- Azure.Core (>= 1.35.0)
- Azure.Identity (>= 1.10.3)
- Microsoft.Identity.Client (>= 4.56.0)
- Microsoft.Identity.Client.Broker (>= 4.56.0)
- Microsoft.Identity.Client.Extensions.Msal (>= 4.56.0)
- System.Memory (>= 4.5.4)
- System.Security.Cryptography.ProtectedData (>= 4.7.0)
- System.Text.Json (>= 4.7.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.0
- Azure.Core (>= 1.35.0)
- Azure.Identity (>= 1.10.3)
- Microsoft.Identity.Client (>= 4.56.0)
- Microsoft.Identity.Client.Broker (>= 4.56.0)
- Microsoft.Identity.Client.Extensions.Msal (>= 4.56.0)
- System.Memory (>= 4.5.4)
- System.Security.Cryptography.ProtectedData (>= 4.7.0)
- System.Text.Json (>= 4.7.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net6.0
- Azure.Core (>= 1.35.0)
- Azure.Identity (>= 1.10.3)
- Microsoft.Identity.Client (>= 4.56.0)
- Microsoft.Identity.Client.Broker (>= 4.56.0)
- Microsoft.Identity.Client.Extensions.Msal (>= 4.56.0)
- System.Memory (>= 4.5.4)
- System.Security.Cryptography.ProtectedData (>= 4.7.0)
- System.Text.Json (>= 4.7.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Azure.Identity.Broker:
Repository | Stars |
---|---|
Azure/azure-powershell
Microsoft Azure PowerShell
|
|
microsoftgraph/msgraph-sdk-powershell
Powershell SDK for Microsoft Graph
|
Version | Downloads | Last updated | |
---|---|---|---|
1.2.0 | 479 | 11/18/2024 | |
1.2.0-beta.1 | 825 | 4/24/2024 | |
1.1.0 | 35,766 | 4/9/2024 | |
1.1.0-beta.1 | 201 | 2/6/2024 | |
1.0.0 | 9,056 | 11/7/2023 | |
1.0.0-beta.5 | 11,233 | 10/19/2023 |