Microsoft Identity Web authentication library
Microsoft Identity Web is a set of ASP.NET Core libraries that simplifies adding authentication and authorization support to web apps and web APIs integrating with the Microsoft identity platform. It provides a single-surface API convenience layer that ties together ASP.NET Core, its authentication middleware, and the Microsoft Authentication Library (MSAL) for .NET. It can be installed via NuGet or by using a Visual Studio project template to create a new app project
Supported application scenarios
When building ASP.NET Core web apps or web APIs that use Azure Active Directory (Azure AD) or Azure AD B2C for identity and access management (IAM), Microsoft Identity Web is recommended for these scenarios:
- Web app that signs in users
- Web app that signs in users and calls a web API on their behalf
- Protected web API that only authenticated users can access
- Protected web API that calls another (downstream) web API on behalf of the signed-in user
Install from NuGet
Microsoft Identity Web is available on NuGet as a set of packages that provide modular functionality based on application requirements. Use the .NET CLI's dotnet add command or Visual Studio's NuGet Package Manager to install the appropriate packages:
- Microsoft.Identity.Web - The main package. Required by all apps that use Microsoft Identity Web.
- Microsoft.Identity.Web.UI - Optional. Adds UI for user sign-in and sign-out and an associated controller for web apps.
- Microsoft.Identity.Web.MicrosoftGraph - Optional. Provides simplified interaction with the Microsoft Graph API.
- Microsoft.Identity.Web.MicrosoftGraphBeta - Optional. Provides simplified interaction with the Microsoft Graph API beta endpoint.
Install by using a Visual Studio project template
Several project templates that use Microsoft.Identity.Web are included in .NET SDK versions 6.0 and above.
.NET 6.0+ - Project templates included
The Microsoft Identity Web project templates are included in .NET SDK versions 6.0 and above.
In the following example, .NET CLI command creates a Blazor Server project that includes Microsoft Identity Web.
dotnet new blazorserver --auth SingleOrg --calls-graph --client-id "00000000-0000-0000-0000-000000000000" --tenant-id "11111111-1111-1111-1111-111111111111" --output my-blazor-app
Don't append a 2 to the application type argument, blazorserver in the example, because templates included in .NET SDK 6.0+ are being used.
Next steps
To see Microsoft Identity Web in action, try our Blazor Server tutorial:
Tutorial: Create a Blazor Server app that uses the Microsoft identity platform for authentication
The Microsoft Identity Web wiki on GitHub contains extensive reference documentation for various aspects of the library. For example, certificate usage, incremental consent, and conditional access reference can be found here: