I am trying to using Auth.js v5 to login with microsoft from any organisation. I have been troubleshooting this for so long and I have tried this with supabase auth. It worked first try logging in with an organisation account, but I don’t want to use supabase, I want to use next-auth. Below are my auth files:
auth.ts:
import NextAuth from "next-auth";
import EntraId from "next-auth/providers/microsoft-entra-id";
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
EntraId({
clientId: process.env.AUTH_AZURE_AD_ID,
clientSecret: process.env.AUTH_AZURE_AD_SECRET,
tenantId: process.env.AUTH_AZURE_AD_TENANT_ID,
authorization: {
url: `https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize`,
params: {
scope: "openid",
},
},
}),
],
});
app/api/auth/[…nextauth]/route.ts:
import { handlers } from "@/auth";
export const { GET, POST } = handlers;