Azure AD B2C Provider
Resources
- Azure Active Directory B2C documentation
 - What is Azure AD B2C
 - Azure AD B2C Tenant
 - App Registration
 - User Flow
 
Setup
Environment Variables
AUTH_AZURE_AD_B2C_ID
AUTH_AZURE_AD_B2C_SECRET
AUTH_AZURE_AD_B2C_ISSUERConfiguration
/auth.ts
import NextAuth from "next-auth";
import AzureADB2C from "next-auth/providers/azure-ad-b2c";
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [AzureADB2C({
    clientId: AUTH_AZURE_AD_B2C_CLIENT_ID
    clientSecret: AUTH_AZURE_AD_B2C_CLIENT_SECRET
    issuer: AUTH_AZURE_AD_B2C_ISSUER
  })]
});Tenant Setup
Basic configuration sets up Azure AD B2C to return an ID Token. This should be done as a prerequisite prior to running through the Advanced configuration. In the Tenant Setup, make sure to set the following during “User attributes and token claims”.
- Collect attribute:
- Email Address
 - Display Name
 - Given Name
 - Surname
 
 - Return claim:
- Email Addresses
 - Display Name
 - Given Name
 - Surname
 - Identity Provider
 - Identity Provider Access Token
 - User’s Object ID