Next.js Discord

Discord Forum

Next-auth discord help

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Avatar
Asiatic LionOP
I logged in via next-auth using the code
import NextAuth from "next-auth/next";
import DiscordProvider from "next-auth/providers/discord";

const authOptions = {
    providers: [
        DiscordProvider({
          clientId: process.env.DISCORD_CLIENT_ID,
          clientSecret: process.env.DISCORD_CLIENT_SECRET,
          authorization: { params: { scope: 'identify guilds' } },
        })
    ],   
    callbacks: {
      async jwt({ token, account, profile }) {
        // Persist the OAuth access_token and or the user id to the token right after signin
        if (account) {
          token.accessToken = account.access_token
          token.id = profile.id
        }
        return token
      },
      async session({ session, token, user }) {
        // Send properties to the client, like an access_token and user id from a provider.
        session.accessToken = token.accessToken
        session.user.id = token.id
        return session
      }
    }
}

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST }

And how do I display a list of user guilds on the site, namely the name of the guild, I Googled and found something, but for some reason it does not display anything. I will be grateful for your help, thank you in advance

0 Replies