Microsoft Entra ID login shows “Access Denied – You do not have permission to sign in” with NextAuth v5 (Auth.js) and Next.js 15
10:05 24 Dec 2025

I’m integrating Microsoft Entra ID authentication using Auth.js / NextAuth v5 (beta) with Next.js 15, but after clicking Sign in, I get the following error screen:

Access Denied You do not have permission to sign in.

The login page appears correctly, but authentication fails immediately after redirecting back from Microsoft.

Tech Stack

Next.js: 15.3.4

Auth.js / NextAuth: ^5.0.0-beta.29

Also set redirection Urls:

rootUrl/api/auth/callback/microsoft-entra-id

Provider: Microsoft Entra ID (Azure AD)

Provider Configuration

  // app/api/auth/[...nextauth]/route.ts
import NextAuth from "next-auth";
import MicrosoftEntraID from "next-auth/providers/microsoft-entra-id";

export const { handlers } = NextAuth({
  trustHost: true,
  debug: true,
  session: { strategy: "jwt" },

  providers: [
    MicrosoftEntraID({
      clientId: process.env.NEXTAUTH_MICROSOFT_ENTRA_ID!,
      clientSecret: process.env.NEXTAUTH_MICROSOFT_ENTRA_ID_SECRET!,
      issuer: process.env.NEXTAUTH_MICROSOFT_ENTRA_ID_ISSUER,
    }),
  ],

  callbacks: {
    async signIn({ account, profile }) {
      // Allow Microsoft Entra ID users only
      if (account?.provider === "microsoft-entra-id") {
        return true;
      }
      return false;
    },
  },
});

login.tsx

 "use client";

import { signIn } from "next-auth/react";

export default function Login() {
  return (
    
  );
}

enter image description here

next.js next-auth microsoft-entra-id next.js15