Extend next-auth session with drizzle adapter

I followed the steps to extend the next-auth session object with a custom userRole property. I extended the Session and User interface, I have the userRole property in my Users DB table and I include the role in the session callback in authOptions. The only type error that I am getting is from the adapter (DrizzleAdapter). But when I check the session object the role property is missing. I've searched everywhere but I cannot figure it out or find a solution. Does anyone have the same problem or know a fix?
No description
51 Replies
IkBenJur
IkBenJur12mo ago
I have never done this myself but reading the docs. Did you add the profile callback in the providers array? This is what the docs says for adding roles to users: The profile() callback's return value is used to create users in the database. That's it! Your newly created users will now have an assigned role. If you also want to use the role on the client, you can expose it via the session callback.
No description
IkBenJur
IkBenJur12mo ago
The link if you want to read the rest btw https://authjs.dev/guides/basics/role-based-access-control
Role-based access control | Auth.js
There are two ways to add role-based access control (RBAC) to your application, based on the session strategy you choose. Let's see an example for each of these.
IkBenJur
IkBenJur12mo ago
Actually now that I’m thinking. Did you set a default value for the role in your schema? Let’s say you create a new user in your db and you don’t set the role manually. Don’t have a default value set in the schema either and try to access the role through user.role in the session. The user.role will be empty and thus the role field will never be passed along right? Or am I thinking wrong
Steve Melons
Steve Melons12mo ago
Thanks for the feedback, and yes I have done all those things. I figured it out. It is actually a bug. The next-auth Drizzle Adapter only fetches the defaults from the db I created an issue but sadly it keeps getting closed because of the reproduction 😦
Steve Melons
Steve Melons12mo ago
GitHub
DrizzleAdapter overwrites custom tables with defaults · Issue #9296...
Adapter type @auth/drizzle-adapter Environment System: OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa) CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K Memory: 11.79 GB / 15.49 GB Container: Yes ...
AnonymousSmoothBrain
+1 to this bug
EnricoBaivo
EnricoBaivo11mo ago
Hello Steve Melons, did you find a solution to extend the User data that is inserted on create ?
stunaz
stunaz11mo ago
what i found is that, it just doesnt work using database as session strategy. its work when you are using jwt as the session strategie, then additionnal fiels are stored with in the jwt token, and you retrieve if from there to add to your session
Josh
Josh11mo ago
this works fine in my repo
Josh
Josh11mo ago
GitHub
GitHub - GentikSolm/t3-app-dir: t3 app dir boilerplate
t3 app dir boilerplate. Contribute to GentikSolm/t3-app-dir development by creating an account on GitHub.
Josh
Josh11mo ago
I'm about to massively overhaul that repo, bit it should show you how to extend it it not really a bug as much as it is an adapter issue. they can't do much from their end because they have drizzle orm files inhouse for the user table so their user data is actually different from yours in the drizzle adapter this works with extra columns, it just won't grab them unless you explicitly override them which is what I did, and honestly it's not much worth at all and even gives you a better idea of what's going on under the hood
EnricoBaivo
EnricoBaivo11mo ago
Thanks for you responses ! Yeah, due to research i also ended up making my own adapter, but i am struggling with the correct Typeing.
declare module "@auth/core/adapters" {
interface AdapterUser {
id: string;
email: string;
emailVerified: Date | null;
image: string;
osuUserId: number;
isAdmin: boolean;
isAlphaTester: boolean;
isBetaTester: boolean;
isNew: boolean;
createdAt: Date | null;
updatedAt: Date | null;
lastLogin: Date | null;
}
}
declare module "@auth/core/types" {
interface AdapterUser {
emailVerified: Date | null;
osuUserId: number;
username: string;
isAdmin: boolean;
image: string;
isAlphaTester: boolean;
isBetaTester: boolean;
isNew: boolean;
createdAt: Date | null;
updatedAt: Date | null;
lastLogin: Date | null;
}
}
declare module "@auth/core/adapters" {
interface AdapterUser {
id: string;
email: string;
emailVerified: Date | null;
image: string;
osuUserId: number;
isAdmin: boolean;
isAlphaTester: boolean;
isBetaTester: boolean;
isNew: boolean;
createdAt: Date | null;
updatedAt: Date | null;
lastLogin: Date | null;
}
}
declare module "@auth/core/types" {
interface AdapterUser {
emailVerified: Date | null;
osuUserId: number;
username: string;
isAdmin: boolean;
image: string;
isAlphaTester: boolean;
isBetaTester: boolean;
isNew: boolean;
createdAt: Date | null;
updatedAt: Date | null;
lastLogin: Date | null;
}
}
`
Type '(data: Omit<AdapterUser, "id">) => Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type '(user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>'.
Type 'Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type 'Awaitable<AdapterUser>'.
Type 'Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type 'PromiseLike<AdapterUser>'.
Types of property 'then' are incompatible.
Type '<TResult1 = AdapterUser | { [x: string]: any; } | undefined, TResult2 = never>(onfulfilled?: ((value: AdapterUser | { [x: string]: any; } | undefined) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = AdapterUser, TResult2 = never>(onfulfilled?: ((value: AdapterUser) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => PromiseLike<...>'.
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'AdapterUser | { [x: string]: any; } | undefined' is not assignable to type 'AdapterUser'.
Type 'undefined' is not assignable to type 'AdapterUser'.ts(2322)
adapters.d.ts(257, 5): The expected type comes from property 'createUser' which is declared here on type 'Adapter'
Type '(data: Omit<AdapterUser, "id">) => Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type '(user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>'.
Type 'Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type 'Awaitable<AdapterUser>'.
Type 'Promise<AdapterUser | { [x: string]: any; } | undefined>' is not assignable to type 'PromiseLike<AdapterUser>'.
Types of property 'then' are incompatible.
Type '<TResult1 = AdapterUser | { [x: string]: any; } | undefined, TResult2 = never>(onfulfilled?: ((value: AdapterUser | { [x: string]: any; } | undefined) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = AdapterUser, TResult2 = never>(onfulfilled?: ((value: AdapterUser) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => PromiseLike<...>'.
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'AdapterUser | { [x: string]: any; } | undefined' is not assignable to type 'AdapterUser'.
Type 'undefined' is not assignable to type 'AdapterUser'.ts(2322)
adapters.d.ts(257, 5): The expected type comes from property 'createUser' which is declared here on type 'Adapter'
`
Josh
Josh11mo ago
just look at the repo I linked and check out how I do it
Dor
Dor11mo ago
why is this working out of the box with Prisma but not with drizzle? they need to fix this. I wasted 2 days finding solutions
Josh
Josh11mo ago
this is not a paid product, it is open source. if it want something fixed that badly do it yourself. these people are working completely for free on these amazing projects. just because it doesn't exactly fit your needs gives you no right to be angry about it
EnricoBaivo
EnricoBaivo11mo ago
I mean i did it also like you did but im using MySQL and i cant return on insert. So i do a select return but this could be null and the create callback dosent allow that:
async createUser(data) {
const id = crypto.randomUUID();
await client.insert(users).values({ ...data, id });
return await client.query.users
.findFirst({
where: (fields, operations) => operations.eq(fields.id, id),
})
.then((res) => res ?? null);
},
async createUser(data) {
const id = crypto.randomUUID();
await client.insert(users).values({ ...data, id });
return await client.query.users
.findFirst({
where: (fields, operations) => operations.eq(fields.id, id),
})
.then((res) => res ?? null);
},
.....updatedAt: string; } | null' is not assignable to type 'AdapterUser'.
Type 'null' is not assignable to type 'AdapterUser'.ts(2322)
.....updatedAt: string; } | null' is not assignable to type 'AdapterUser'.
Type 'null' is not assignable to type 'AdapterUser'.ts(2322)
Josh
Josh11mo ago
1. you shouldnt be mixing .then with await 2. since we just inserted the user, we can be very sure the user exists in the db, so you can safely tell typescript that it will for sure not be null
Dinocan
Dinocan10mo ago
I found the solution for my project, I hope it will be a solution for you too.
import { env } from "@/env";
import { db } from "@/server/db";
import { accounts, sessions, sqliteTable, users, verificationTokens } from "@/server/db/schema";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { type SQLiteTableFn } from "drizzle-orm/sqlite-core";
import {
getServerSession,
type DefaultSession,
type NextAuthOptions,
} from "next-auth";
import type { Adapter } from 'next-auth/adapters';
import DiscordProvider from "next-auth/providers/discord";

declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
role: "BANNED" | "USER" | "MODERATOR" | "ADMIN";
points: number;
} & DefaultSession["user"];
}

interface User {
role: "BANNED" | "USER" | "MODERATOR" | "ADMIN";
points: number;
}
}

type TableFnParams = Parameters<SQLiteTableFn>;
function dumbAdapter (
name: TableFnParams[0],
columns: TableFnParams[1],
extraConfig: TableFnParams[2],
) {
switch (name) {
case "user":
return users;
case "account":
return accounts;
case "session":
return sessions;
case "verification_token":
return verificationTokens;
default:
return sqliteTable(name, columns, extraConfig);
}
};

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
role: user.role,
points: user.points,
},
}),
},
adapter: DrizzleAdapter(db, dumbAdapter as SQLiteTableFn<undefined>) as Adapter,
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
],
};

export const getServerAuthSession = () => getServerSession(authOptions);
import { env } from "@/env";
import { db } from "@/server/db";
import { accounts, sessions, sqliteTable, users, verificationTokens } from "@/server/db/schema";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { type SQLiteTableFn } from "drizzle-orm/sqlite-core";
import {
getServerSession,
type DefaultSession,
type NextAuthOptions,
} from "next-auth";
import type { Adapter } from 'next-auth/adapters';
import DiscordProvider from "next-auth/providers/discord";

declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
role: "BANNED" | "USER" | "MODERATOR" | "ADMIN";
points: number;
} & DefaultSession["user"];
}

interface User {
role: "BANNED" | "USER" | "MODERATOR" | "ADMIN";
points: number;
}
}

type TableFnParams = Parameters<SQLiteTableFn>;
function dumbAdapter (
name: TableFnParams[0],
columns: TableFnParams[1],
extraConfig: TableFnParams[2],
) {
switch (name) {
case "user":
return users;
case "account":
return accounts;
case "session":
return sessions;
case "verification_token":
return verificationTokens;
default:
return sqliteTable(name, columns, extraConfig);
}
};

export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
role: user.role,
points: user.points,
},
}),
},
adapter: DrizzleAdapter(db, dumbAdapter as SQLiteTableFn<undefined>) as Adapter,
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
],
};

export const getServerAuthSession = () => getServerSession(authOptions);
Yiannis
Yiannis10mo ago
I found a solution to this a while ago by julius: https://github.com/nextauthjs/next-auth/pull/8561
GitHub
feat(adapter-drizzle): add option to pass in schema by juliusmarmin...
☕️ Reasoning In other adapters, the adapter returns the entire table so if you have additional fields they will also be returned when the adapter queries the table. A good example here is if your ...
Yiannis
Yiannis10mo ago
basically overrides a function of the drizzle adaptor. Still need to augment the interface and add the field to the db, but now the adaptor will actually fetch it
Yiannis
Yiannis10mo ago
You need to also make sure you augment the right module https://github.com/nextauthjs/next-auth/pull/9462
GitHub
fix(docs): updated typescript module imports by Huijiro · Pull Requ...
☕️ Reasoning As discussed in #8948, #9253, and #9377, some augmentation of types in the documentation is wrong, this pull request aims to solve those issues by updating the documentation. I also ad...
Liltripple_reid
Liltripple_reid10mo ago
hey @Steve Melons (or anyone on this thread) did you by any chance also came across the typeError gave by the drizzle-adapter? I just created a new t3-app and I'm getting this
Type 'import("/Users/a3tech/Developer/personal_projects/pathways/node_modules/.pnpm/@[email protected]/node_modules/@auth/core/adapters").Adapter' is not assignable to type 'import("/Users/a3tech/Developer/personal_projects/pathways/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/adapters").Adapter'.
Types of property 'createUser' are incompatible.
Type '((user: AdapterUser) => Awaitable<AdapterUser>) | undefined' is not assignable to type '((user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>) | undefined'.
Type '(user: AdapterUser) => Awaitable<AdapterUser>' is not assignable to type '(user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>'.
Type 'import("/Users/a3tech/Developer/personal_projects/pathways/node_modules/.pnpm/@[email protected]/node_modules/@auth/core/adapters").Adapter' is not assignable to type 'import("/Users/a3tech/Developer/personal_projects/pathways/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/adapters").Adapter'.
Types of property 'createUser' are incompatible.
Type '((user: AdapterUser) => Awaitable<AdapterUser>) | undefined' is not assignable to type '((user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>) | undefined'.
Type '(user: AdapterUser) => Awaitable<AdapterUser>' is not assignable to type '(user: Omit<AdapterUser, "id">) => Awaitable<AdapterUser>'.
Steve Melons
Steve Melons10mo ago
Does it build when you @ts-ignore ? I think I had the same issue
Liltripple_reid
Liltripple_reid10mo ago
it does but the sign-in/up flows on my prod website and local are completely broken
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error invalid_client (The OAuth client was not found.) {
error: OPError: invalid_client (The OAuth client was not found.)
at processResponse (/var/task/.next/server/chunks/9148.js:14953:19)
at Client.grant (/var/task/.next/server/chunks/9148.js:13481:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.callback (/var/task/.next/server/chunks/9148.js:12693:30)
at async oAuthCallback (/var/task/.next/server/chunks/9148.js:7874:22)
at async Object.callback (/var/task/.next/server/chunks/9148.js:8783:79)
at async AuthHandler (/var/task/.next/server/chunks/9148.js:6682:38)
at async NextAuthRouteHandler (/var/task/.next/server/chunks/9148.js:9696:30)
at async NextAuth._args$ (/var/task/.next/server/chunks/9148.js:9731:24)
at async /var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:41960 {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'google',
message: 'invalid_client (The OAuth client was not found.)'
}
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error invalid_client (The OAuth client was not found.) {
error: OPError: invalid_client (The OAuth client was not found.)
at processResponse (/var/task/.next/server/chunks/9148.js:14953:19)
at Client.grant (/var/task/.next/server/chunks/9148.js:13481:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.callback (/var/task/.next/server/chunks/9148.js:12693:30)
at async oAuthCallback (/var/task/.next/server/chunks/9148.js:7874:22)
at async Object.callback (/var/task/.next/server/chunks/9148.js:8783:79)
at async AuthHandler (/var/task/.next/server/chunks/9148.js:6682:38)
at async NextAuthRouteHandler (/var/task/.next/server/chunks/9148.js:9696:30)
at async NextAuth._args$ (/var/task/.next/server/chunks/9148.js:9731:24)
at async /var/task/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:41960 {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'google',
message: 'invalid_client (The OAuth client was not found.)'
}
I'm getting this error with credentials I've used before I literally just updated dependencies and started getting a lot of errors from nextauth and the drizzle adapter
Yiannis
Yiannis10mo ago
import type { Adapter } from "next-auth/adapters"; Needs a different import I think
Liltripple_reid
Liltripple_reid10mo ago
I have no type Adapter imported here 😦
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { mysqlTable } from "drizzle-orm/mysql-core";
import { NextAuthOptions } from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
import GoogleProvider from "next-auth/providers/google";
import { db } from "../db";
import { env } from "../env.mjs";

export const authOptions: NextAuthOptions = {
// @ts-expect-error weird
adapter: DrizzleAdapter(db, mysqlTable),
callbacks: {
jwt: ({ account, token, user }) => {
if (account && user) {
token.accessToken = account.access_token;
token.id = user.id;
}

return token;
},
session: ({ session, token }) => {
return {
...session,
user: {
...session.user,
id: token.id,
username: token.username,
},
};
},
},
secret: env.NEXTAUTH_SECRET,
session: {
strategy: "jwt",
},
pages: {
signIn: "/auth/signin",
signOut: "/auth/bye",
error: "/auth/signin",
newUser: "/auth/setup?goBackTo=/home",
},
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
}),
],
};
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { mysqlTable } from "drizzle-orm/mysql-core";
import { NextAuthOptions } from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
import GoogleProvider from "next-auth/providers/google";
import { db } from "../db";
import { env } from "../env.mjs";

export const authOptions: NextAuthOptions = {
// @ts-expect-error weird
adapter: DrizzleAdapter(db, mysqlTable),
callbacks: {
jwt: ({ account, token, user }) => {
if (account && user) {
token.accessToken = account.access_token;
token.id = user.id;
}

return token;
},
session: ({ session, token }) => {
return {
...session,
user: {
...session.user,
id: token.id,
username: token.username,
},
};
},
},
secret: env.NEXTAUTH_SECRET,
session: {
strategy: "jwt",
},
pages: {
signIn: "/auth/signin",
signOut: "/auth/bye",
error: "/auth/signin",
newUser: "/auth/setup?goBackTo=/home",
},
providers: [
DiscordProvider({
clientId: env.DISCORD_CLIENT_ID,
clientSecret: env.DISCORD_CLIENT_SECRET,
}),
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_CLIENT_SECRET,
}),
],
};
my whole file
Yiannis
Yiannis10mo ago
You may need to augment the type and include the user id
Yiannis
Yiannis10mo ago
@Liltripple_reid According to this you should just cast it for now. https://github.com/nextauthjs/next-auth/issues/9493
import type { Adapter } from 'next-auth/adapters';

[...]
adapter: PrismaAdapter(prisma) as Adapter
import type { Adapter } from 'next-auth/adapters';

[...]
adapter: PrismaAdapter(prisma) as Adapter
GitHub
Types of property 'createUser' are incompatible · Issue #9493 · nex...
Environment System: OS: Windows 11 10.0.22000 CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor Memory: 88.88 GB / 127.94 GB Binaries: Node: 20.6.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 ...
Liltripple_reid
Liltripple_reid10mo ago
I’ll try that will update soon Update: the ts errors are out, but the sign in errors are still there
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error invalid_client (The OAuth client was not found.) {
error: OPError: invalid_client (The OAuth client was not found.)
at Client.grant (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/openid-client/lib/client.js:1206:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.callback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/openid-client/lib/client.js:418:30)
at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/lib/oauth/callback.js:118:22)
at async Object.callback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/routes/callback.js:18:79)
at async AuthHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/index.js:202:38)
at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:50:30)
at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:85:24)
at async /Users/a3tech/Developer/personal_projects/chronosecrets/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63251 {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'google',
message: 'invalid_client (The OAuth client was not found.)'
}
[next-auth][error][OAUTH_CALLBACK_ERROR]
https://next-auth.js.org/errors#oauth_callback_error invalid_client (The OAuth client was not found.) {
error: OPError: invalid_client (The OAuth client was not found.)
at Client.grant (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/openid-client/lib/client.js:1206:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.callback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected]/node_modules/openid-client/lib/client.js:418:30)
at async oAuthCallback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/lib/oauth/callback.js:118:22)
at async Object.callback (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/routes/callback.js:18:79)
at async AuthHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/core/index.js:202:38)
at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:50:30)
at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next-auth/next/index.js:85:24)
at async /Users/a3tech/Developer/personal_projects/chronosecrets/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63251 {
name: 'OAuthCallbackError',
code: undefined
},
providerId: 'google',
message: 'invalid_client (The OAuth client was not found.)'
}
Yiannis
Yiannis10mo ago
Double check your env variables?
Liltripple_reid
Liltripple_reid10mo ago
100 times same error "Client not found"
Yiannis
Yiannis10mo ago
is your repo public ?
Liltripple_reid
Liltripple_reid10mo ago
wait do discord's or google's client_secret keys expire?
Yiannis
Yiannis10mo ago
no
Liltripple_reid
Liltripple_reid10mo ago
huh I'll deploy and test this out again
Yiannis
Yiannis10mo ago
In an hour or so I mihgt have some time to do a test. You are uing the pirsma adapter and stock t3 with the @ latest ?
Liltripple_reid
Liltripple_reid10mo ago
drizzle adapter
Yiannis
Yiannis10mo ago
Ok sounds good. Can you send your package.json ?
Liltripple_reid
Liltripple_reid10mo ago
you can check out the repo and deployed url here https://github.com/statusunknown418/chronosecrets
GitHub
GitHub - statusunknown418/chronosecrets: A (rather different?) new ...
A (rather different?) new social media to schedule and share encrypted messages - GitHub - statusunknown418/chronosecrets: A (rather different?) new social media to schedule and share encrypted mes...
Liltripple_reid
Liltripple_reid10mo ago
was planning on doing a kinda fancy product launch but started getting this auth stuff
Yiannis
Yiannis10mo ago
looks nice! Will clone when i get a chance and will get back to you
Liltripple_reid
Liltripple_reid10mo ago
thanks man, lmk if you can find anything 🙏
Yiannis
Yiannis10mo ago
I remeber having this issue then i moved to atuhjs5 beta and it was gone
Liltripple_reid
Liltripple_reid10mo ago
well it could be a good upgrade, thing is that it's still on "beta"
Yiannis
Yiannis10mo ago
Yeah the docs need love but it can run on the edge runtime since you are using Drizzle if you deploy on vercel which is a plus.
Liltripple_reid
Liltripple_reid10mo ago
Well if I can’t find a solution I think I’ll just upgrade Is it too much code to change?
Yiannis
Yiannis10mo ago
Hey sorry I got really busy last night. I'm gonna take a look today and get back to you. It is a good amount, those docs are ok though (the upgrading ones).
Liltripple_reid
Liltripple_reid10mo ago
shesh no worries but I think I found a fix for some reason upgrading running pnpm up again solved the thing found this related
Liltripple_reid
Liltripple_reid10mo ago
GitHub
Google provider not working in @auth/core 0.19.1 · Issue #9558 · ne...
Provider type Google Environment System: OS: Windows 11 10.0.22621 CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor Memory: 5.83 GB / 15.91 GB Binaries: Node: 18.18.2 - C:\Program Files\nodejs\node....
Yiannis
Yiannis10mo ago
So is it all fixed now?
Liltripple_reid
Liltripple_reid10mo ago
looks like so
Want results from more Discord servers?
Add your server