callbackUrl=%2F&error=OAuthAccountNotLinked

Anyone run into this before with Google Provider? Heres the link to the repo: https://github.com/DollaHane/PepperMint. The user is created in the db on sign-in but I've got no session. Also the "session", "account" and "tokenVerification" tables are still empty after sign-in. This is my redirect URI: http://localhost:3000/api/auth/callback/google
1 Reply
dollahane23033
dollahane2303312mo ago
"/lib/auth.ts" : import { db } from '@/src/db/index' import { eq } from 'drizzle-orm' import { DrizzleAdapter } from '@auth/drizzle-adapter' import type { NextAuthOptions } from 'next-auth' import { getServerSession } from 'next-auth' import GoogleProvider from 'next-auth/providers/google' import { users } from '../db/schema' export const authOptions: NextAuthOptions = { adapter: DrizzleAdapter(db), session: { strategy: 'jwt', }, secret: process.env.NEXTAUTH_SECRET, pages: { signIn: '/signin', }, providers: [ GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }), ], callbacks: { async session({ token, session }) { if (token) { session.user.id = token.id; session.user.name = token.name; session.user.email = token.email; session.user.image = token.picture; } return session; }, async jwt({ token, user }) { const [dbUser] = await db .select() .from(users) .where(eq(users.email, token.email || '')) .limit(1); if (!dbUser) { if (user) { token.id = user?.id; } return token; } return { id: dbUser.id, name: dbUser.name, email: dbUser.email, picture: dbUser.image, }; }, redirect() { return '/' }, }, } export const getAuthSession = () => getServerSession(authOptions) Update on this error, I seemed to have found a fix. I was using the Drizzle-Adapter from Next-Auth, which didnt seem to be working for my project. Instead I found the adapter from this repo worked: https://github.com/miljan-code/drizzle-next-auth/tree/main. I also copied the user, account and session schema just incase.
Want results from more Discord servers?
Add your server