Next.js Discord

Discord Forum

Next-auth Login with Xbox

Unanswered
Alopekis posted this in #help-forum
Open in Discord
Avatar
AlopekisOP
I want to make a sign in with xbox feature on my web app with Next-auth, all I want is to have the Xbox Gamertag on my session, but I can't get it and couldn't find anything useful on this matter. Here is my code.

import NextAuth, { NextAuthOptions } from "next-auth";
import AzureADProvider from "next-auth/providers/azure-ad";

const authOptions: NextAuthOptions = {
    secret: process.env.NEXTAUTH_SECRET,
    session: {
        strategy: 'jwt',
        maxAge: 30 * 24 * 60 * 60,
        updateAge: 60 * 60
    },
    providers: [
        AzureADProvider({
            clientId: process.env.AZURE_AD_CLIENT_ID as string,
            clientSecret: process.env.AZURE_AD_CLIENT_SECRET as string,
            tenantId: 'consumers',
            httpOptions: { timeout: 10000 },
            authorization: { params: { scope: "openid offline_access profile XboxLive.signin", display: "touch"},},
            profile(profile, tokens) {
              console.log(profile, tokens)
              return {
                id: profile.oid,
                name: profile.name,
                email: profile.name
              }
            }
        })
    ],
}

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };


Anyone that is a master on Azure Directory or something like that to help me? I am kind of a newbie on this

0 Replies