Samples for customer identity and access management (CIAM) in Microsoft Entra External ID

Microsoft maintains code samples that demonstrate how to integrate various application types with Microsoft Entra External ID. We provide instructions for downloading and using samples or building your own app based on common authentication and authorization scenarios, development languages, and platforms. Included are instructions for building the project (if applicable) and running the sample application. Within the sample code, comments help you understand how these libraries are used in the application to perform authentication and authorization in an external tenant.

Samples and guides

Use the tabs to sort samples either by app type or your preferred language/platform.

Single-page application (SPA)

These samples and how-to guides demonstrate how to integrate a single-page application with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
JavaScript, Vanilla Sign in users Sign in users
JavaScript, Angular Sign in users ---
JavaScript, React Sign in users Sign in users

Web app

These samples and how-to guides demonstrate how to write a web application that integrates with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
JavaScript, Node.js (Express) Sign in users
Sign in users and call an API
Sign in users
Sign in users and call an API
ASP.NET Core Sign in users Sign in users
Python Django Sign in users ---
Python Flask Sign in users ---

Web API

These samples and how-to guides demonstrate how to protect a web API with the Microsoft identity platform, and how to call a downstream API from the web API.

Language/
Platform
Code sample guide Build and integrate guide
ASP.NET Core --- Secure an ASP.NET web API

Desktop

These samples and how-to guides demonstrate how to write a desktop application that integrates with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
JavaScript, Electron Sign in users ---
ASP.NET (MAUI) Sign in users Sign in users

Mobile: Browser delegated

These samples and how-to guides demonstrate how to write a public client mobile application with browser delegated authentication that integrates with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
ASP.NET Core MAUI Sign in users Sign in users

Mobile: Native authentication

These samples and how-to guides demonstrate how to write a public client mobile application with native authentication that integrates with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
Android (Kotlin) Sign in users Sign in users
iOS (Swift) Sign in users Sign in users

Daemon

These samples and how-to guides demonstrate how to write a daemon application that integrates with Microsoft Entra External ID.

Language/
Platform
Code sample guide Build and integrate guide
Node.js Call an API Call an API
.NET Call an API Call an API