skip to Main Content

I am making a sign up page with 3 providers (Twitter, Facebook and Instagram) using next-auth and prisma with mongoDB. The issue appears when I try to sign up with any of the providers. Here is my nextauth.js file.

import NextAuth from "next-auth"

import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaClient } from '@prisma/client';

import InstagramProvider from "next-auth/providers/instagram";
import TwitterProvider from "next-auth/providers/twitter";
import FacebookProvider from "next-auth/providers/facebook";

const prisma = new PrismaClient();


export default NextAuth({
  adapter: PrismaAdapter(prisma),
  
  providers: [
    InstagramProvider({
      clientId: process.env.INSTAGRAM_CLIENT_ID,
      clientSecret: process.env.INSTAGRAM_CLIENT_SECRET
    }),
    TwitterProvider({
      clientId: process.env.TWITTER_CLIENT_ID,
      clientSecret: process.env.TWITTER_CLIENT_SECRET,
      version: "2.0",
    }),
    FacebookProvider({
      clientId: process.env.FACEBOOK_CLIENT_ID,
      clientSecret: process.env.FACEBOOK_CLIENT_SECRET
    }),

  ],
  session: {
    strategy: 'jwt',
  },
  
});

I have tried to reinstall all the dependencies, because I don’t see what else could be the problem. At first I thought it was the dependencies so I reinstall all the dependencies.

3

Answers


  1. Chosen as BEST ANSWER

    The issue actually comes from the prisma schema. I fixed it after reading the next auth documentation about prisma and mongoDB.


  2. The problem is in your adapter in the [nextauth].js file or wherever you are declaring the prisma instance.

    Check out those similar discussions:

    Login or Signup to reply.
  3. Adding @map("provider_account_id") to the providerAccountId in the Account model in the schema.prisma file worked for me.

    source: bassem97’s solution

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search