Azure Active Directory B2C code samples

The following tables provide links to samples for applications including iOS, Android, .NET, and Node.js.

Mobile and desktop apps

Sample Description
ios-swift-native-msal An iOS sample in Swift that authenticates Azure AD B2C users and calls an API using OAuth 2.0
android-native-msal A simple Android app showcasing how to use MSAL to authenticate users via Azure Active Directory B2C, and access a Web API with the resulting tokens.
ios-native-appauth A sample that shows how you can use a third party library to build an iOS application in Objective-C that authenticates Microsoft identity users to our Azure AD B2C identity service.
android-native-appauth A sample that shows how you can use a third party library to build an Android application that authenticates Microsoft identity users to our B2C identity service and calls a web API using OAuth 2.0 access tokens.
dotnet-desktop A sample that shows how a Windows Desktop .NET (WPF) application can sign in a user using Azure AD B2C, get an access token using MSAL.NET and call an API.
xamarin-native A simple Xamarin Forms app showcasing how to use MSAL to authenticate users via Azure Active Directory B2C, and access a Web API with the resulting tokens.

Web apps and APIs

Sample Description
dotnet-webapp-and-webapi A combined sample for a .NET web application that calls a .NET Web API, both secured using Azure AD B2C.
dotnetcore-webapp-openidconnect An ASP.NET Core web application that uses OpenID Connect to sign in users in Azure AD B2C.
dotnetcore-webapp-msal-api An ASP.NET Core web application that can sign in a user using Azure AD B2C, get an access token using MSAL.NET and call an API.
openidconnect-nodejs A Node.js app that provides a quick and easy way to set up a Web application with Express using OpenID Connect.
javascript-nodejs-webapi A small node.js Web API for Azure AD B2C that shows how to protect your web api and accept B2C access tokens using passport.js.
ms-identity-python-webapp Demonstrate how to Integrate B2C of Microsoft identity platform with a Python web application.

Single page apps

Sample Description
ms-identity-b2c-javascript-spa A single page application (SPA) calling a Web API. Authentication is done with Azure AD B2C by using MSAL.js. This sample uses the authorization code flow with PKCE.
javascript-msal-singlepageapp A single page application (SPA) calling a Web API. Authentication is done with Azure AD B2C by using MSAL.js. This samples uses the implicit flow.

SAML test application

Sample Description
saml-sp-tester SAML test application to test Azure AD B2C configured to act as SAML identity provider.

API connectors

The following tables provide links to code samples for leveraging web APIs in your user flows using API connectors.

Azure Function quickstarts

Sample Description
.NET Core This .NET Core Azure Function sample demonstrates how to limit sign-ups to specific email domains and validate user-provided information.
Node.js This Node.js Azure Function sample demonstrates how to limit sign-ups to specific email domains and validate user-provided information.
Python This Python Azure Function sample demonstrates how to limit sign-ups to specific email domains and validate user-provided information.

Automated fraud protection services & CAPTCHA

Sample Description
Arkose Labs fraud and abuse protection This sample shows how to protect your user sign-ups using using the Arkose Labs fraud and abuse protection service.
reCAPTCHA This sample shows how to protect your user sign-ups using using a reCAPTCHA challenge to prevent automated abuse.

Identity verification

Sample Description
IDology This sample shows how to verify a user identity as part of your sign-up flows by using an API connector to integrate with IDology.
Experian This sample shows how to verify a user identity as part of your sign-up flows by using an API connector to integrate with Experian.

Other

Sample Description
Invitation code This sample demonstrates how to limit sign up to specific audiences by using invitation codes.
API connector community samples This repository has community maintained samples of scenarios enabled by API connectors.