[oidcProvider] trustedClients don't get added to the OauthApplication table in the database.

I have set up two Next.js apps, both with better-auth. One serves as an oidc provider (https://idapp.appname.local), with the oidcProvider plugin installed. The other serves as a consumer of the oidc provider (https://clientapp.appname.local), with the generic oAuth plugin installed. However, when I try to sign in using the oAuth plugin I get the following error: oauth_code_verification_failed Furthermore, in the console of the idApp, I get the following logs:
2025-10-02T15:34:27.784Z ERROR [Better Auth]: PrismaClientKnownRequestError Error [PrismaClientKnownRequestError]: Invalid prisma.oauthAccessToken.create() invocation: Foreign key constraint violated on the foreign key
2025-10-02T15:34:27.784Z ERROR [Better Auth]: PrismaClientKnownRequestError Error [PrismaClientKnownRequestError]: Invalid prisma.oauthAccessToken.create() invocation: Foreign key constraint violated on the foreign key
After some investigation, I noticed that the OauthApplications table in the database is empty. Even after running npx @better-auth/cli generate followed by npx prisma db push, the table is still empty. It seems as if the trustedClients: object in the oidcProvider's config should automatically add these records to the database, but it does not.
1 Reply
PXTRICK
PXTRICKOP3w ago
I have created a GitHub issue for more info: https://github.com/better-auth/better-auth/issues/5040
GitHub
[oidcProvider] trustedClients don't get added to the OauthApplicati...
Is this suited for github? Yes, this is suited for github To Reproduce Set up two Next.js apps, both with better-auth. One serves as an oidc provider (https://idapp.appname.local), with the oidcPro...

Did you find this page helpful?