Missing database behaviour: Add missing field idToken to the database core schema in docs. #506

Closed
opened 2026-03-13 07:50:14 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @walhalla-software-dev on GitHub (Jan 1, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Setup a Nexjts Project with Prisma, Postgres and Google as Auth Provider.
Adapt the default schema shown in the documention (manually schema created)

Compare the core schema from docs with better-auth cli generated schema

Current vs. Expected behavior

Current: The Account Table is not filled doing the signup - signin process with google auth using only the core schema. A BETTER-AUTH error is thrown: unable_to_create_user

Expected: The Setup works with all vanilla settings from docs

What version of Better Auth are you using?

v1.1.8-beta.2

Provide environment information

Nextjs 15
Prisma
Postgres

Vanilla App with prisma schema from better auth docs

Which area(s) are affected? (Select all that apply)

Backend, Documentation

Auth config (if applicable)

import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import db from '@/lib/db'
import { nextCookies } from 'better-auth/next-js'

export const auth = betterAuth({
  database: prismaAdapter(db, {
    provider: 'postgresql',
  }),
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    },
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
  },
  plugins: [nextCookies()],
})

Additional context

GitHub Provider is working without the idToken field, so my setup is correctly done basically
Manually adapted schema:
`generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id String @id
name String
email String @unique
emailVerified Boolean @default(false)
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions Session[]
accounts Account[]
}

model Session {
id String @id
userId String
token String
expiresAt DateTime
ipAddress String?
userAgent String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model Account {
id String @id
userId String
accountId String
providerId String
accessToken String?
refreshToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}`

Schema added by better-auth cli generate:

`generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id String @id
name String
email String
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime
sessions Session[]
accounts Account[]

@@unique([email])
@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime
updatedAt DateTime
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([token])
@@map("session")
}

model Account {
id String @id
accountId String
providerId String
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
accessToken String?
refreshToken String?
idToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
password String?
createdAt DateTime
updatedAt DateTime

@@map("account")
}

model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime?
updatedAt DateTime?

@@map("verification")
}
`

Originally created by @walhalla-software-dev on GitHub (Jan 1, 2025). ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce Setup a Nexjts Project with Prisma, Postgres and Google as Auth Provider. Adapt the default schema shown in the documention (manually schema created) Compare the core schema from docs with better-auth cli generated schema ### Current vs. Expected behavior Current: The Account Table is not filled doing the signup - signin process with google auth using only the core schema. A BETTER-AUTH error is thrown: unable_to_create_user Expected: The Setup works with all vanilla settings from docs ### What version of Better Auth are you using? v1.1.8-beta.2 ### Provide environment information ```bash Nextjs 15 Prisma Postgres Vanilla App with prisma schema from better auth docs ``` ### Which area(s) are affected? (Select all that apply) Backend, Documentation ### Auth config (if applicable) ```typescript import { betterAuth } from 'better-auth' import { prismaAdapter } from 'better-auth/adapters/prisma' import db from '@/lib/db' import { nextCookies } from 'better-auth/next-js' export const auth = betterAuth({ database: prismaAdapter(db, { provider: 'postgresql', }), socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID as string, clientSecret: process.env.GITHUB_CLIENT_SECRET as string, }, google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, plugins: [nextCookies()], }) ``` ### Additional context GitHub Provider is working without the idToken field, so my setup is correctly done basically Manually adapted schema: `generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id name String email String @unique emailVerified Boolean @default(false) image String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt sessions Session[] accounts Account[] } model Session { id String @id userId String token String expiresAt DateTime ipAddress String? userAgent String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model Account { id String @id userId String accountId String providerId String accessToken String? refreshToken String? accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? password String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model Verification { id String @id identifier String value String expiresAt DateTime createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }` Schema added by better-auth cli generate: `generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id name String email String emailVerified Boolean image String? createdAt DateTime updatedAt DateTime sessions Session[] accounts Account[] @@unique([email]) @@map("user") } model Session { id String @id expiresAt DateTime token String createdAt DateTime updatedAt DateTime ipAddress String? userAgent String? userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([token]) @@map("session") } model Account { id String @id accountId String providerId String userId String user User @relation(fields: [userId], references: [id], onDelete: Cascade) accessToken String? refreshToken String? idToken String? accessTokenExpiresAt DateTime? refreshTokenExpiresAt DateTime? scope String? password String? createdAt DateTime updatedAt DateTime @@map("account") } model Verification { id String @id identifier String value String expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } `
GiteaMirror added the bug label 2026-03-13 07:50:14 -05:00
Author
Owner

@Bekacru commented on GitHub (Jan 2, 2025):

it's now added

@Bekacru commented on GitHub (Jan 2, 2025): it's now added
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#506