Currently in the process of setting up next auth to integrate with GitHub as a provider. Here is an overview of my setup:
[...nextauth].js
import NextAuth from "next-auth"
import Providers from "next-auth/providers"
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient()
export default NextAuth({
// Configure one or more authentication providers
providers: [
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
Providers.Email({
server: process.env.EMAIL_SERVER,
from: process.env.EMAIL_FROM,
}),
],
adapter: PrismaAdapter(prisma),
})
This is how my prisma schema is structured:
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialActions"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
oauth_token_secret String?
oauth_token String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
After successfully connecting to GitHub and authorizing the application, I encounter this error:
[next-auth][error][prisma__get_user_by_provider_account_id_error]
https://next-auth.js.org/errors#prisma__get_user_by_provider_account_id_error PrismaClientValidationError:
Invalid `prisma.account.findUnique()` invocation:
{
where: {
providerId_providerAccountId: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
providerId: 'github',
providerAccountId: 13868008
}
},
select: {
user: true
}
}
Unknown arg `providerId_providerAccountId` in where.providerId_providerAccountId for type AccountWhereUniqueInput. Did you mean `provider_providerAccountId`? Available args:
type AccountWhereUniqueInput {
id?: String
provider_providerAccountId?: AccountProviderProviderAccountIdCompoundUniqueInput
}
at Document.validate (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:35195:19)
at PrismaClient._executeRequest (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37530:17)
at consumer (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37475:23)
at C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37477:47
at AsyncResource.runInAsyncScope (async_hooks.js:189:9)
at PrismaClient._request (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37477:25)
at request (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37580:77)
at Object.then (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37595:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
clientVersion: '2.30.3'
}
[next-auth][error][oauth_callback_handler_error]
https://next-auth.js.org/errors#oauth_callback_handler_error Error:
Invalid `prisma.account.findUnique()` invocation:
{
where: {
providerId_providerAccountId: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
providerId: 'github',
providerAccountId: 13868008
}
},
select: {
user: true
}
}
Unknown arg `providerId_providerAccountId` in where.providerId_providerAccountId for type AccountWhereUniqueInput. Did you mean `provider_providerAccountId`? Available args:
type AccountWhereUniqueInput {
id?: String
provider_providerAccountId?: AccountProviderProviderAccountIdCompoundUniqueInput
}
at Document.validate (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:35195:19)
at PrismaClient._executeRequest (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37530:17)
at consumer (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37475:23)
at C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37477:47
at AsyncResource.runInAsyncScope (async_hooks.js:189:9)
at PrismaClient._request (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37477:25)
at request (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37580:77)
at Object.then (C:\Users\tfr\Projects\employee-nextjs-gitlab\node_modules\@prisma\client\runtime\index.js:37595:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
name: 'GetUserByProviderAccountIdError'
}
Seeking guidance on what may be going wrong here. Appreciate any assistance.