Next.js Discord

Discord Forum

Next Auth - Azure AD B2C - How to get access token

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
app/api/aut/[...nextauth]/route.ts

import NextAuth from "next-auth";
import AzureADB2CProvider from "next-auth/providers/azure-ad-b2c";

const handler = NextAuth({
  providers: [
    AzureADB2CProvider({
      tenantId: process.env.AZURE_AD_B2C_TENANT_NAME,
      clientId: process.env.AZURE_AD_B2C_CLIENT_ID!,
      clientSecret: process.env.AZURE_AD_B2C_CLIENT_SECRET!,
      primaryUserFlow: process.env.AZURE_AD_B2C_PRIMARY_USER_FLOW,
      authorization: {
        params: {
          scope: "offline_access openid",
        },
      },
      checks: ["pkce"],
      client: {
        token_endpoint_auth_method: "none",
      },
    }),
  ],
});

export { handler as GET, handler as POST };

However from the
useSession
hook. I can only get name, email and image.

0 Replies