Better Auth

BA

Better Auth

Join the community to ask questions about Better Auth and get answers from other members.

Join

bug-reports

help

How to get organization plugin data into OIDC claims

I successfully set up the organization plugin, good stuff. However, I'm unsure how to access this data and set it as user claims for OIDC ID tokens. OIDC plugin getAdditionalUserInfoClaim's first parameter is the user object, but the user's org info isn't listed on this object. Missing something?

how to auth.api.createOIDCProvider without user session

i want to create oauthApps at runtime. but calling createOIDCProvider requires a user session? ```js await auth.api.createOIDCProvider({ body: {...

Organization role customization

Goal: Have only custom roles and access control for organizations Observed Behavior: Things still being created as "owner", I think "admin", "owner" and other roles still exist. I only want my custom roles, and I want the creating user to get the custom role as well ("parent" in this case). Background: I'm building a family management app, using an organization as the "family", and I want to have custom roles for parents and children, etc. I have followed the custom roles/authorization docs for the organization to customize things. Here is what that looks like so far:...

Error FAILED_TO_CREATE_USER with code 42703 when trying to create a new user

I've set up BetterAuth with my React and Vite app, and have tried to set it up with NestJS on the backend I've gotten it to not throw errors on startup, however, when I run ```ts...
Solution:
I had a password row in my table and didnt realize I shouldnt. wasted 10h figuriing that out

GenerateId false is not working

Even with generateId set to false, when I try to login I get the error because its trying to use its own id instead of the db's default ``` export function initAuth() { if (authInstance) {...

Anonymous/API Keys + OIDC

This is just a curiosity/architecture question, not running into a bug or anything! My setup: BA as IDP/OIDC OP, downstream apps as OIDC RPs. My use case: API protected by authentication against BA OIDC OP (all requests throw an error unless valid bearer/access token is present from authenticated user). Web app currently locked down to authenticated users, but want to open up some routes so users can fetch data only from the web app (i.e. not from cURL, postman, insomnia)...

Getting session from external server on a different server

Basically I have two backends here: one for TanStack Start's SSR, and one for Better Auth and the site's API (using Hono). Before this change, I got the user's session on the Start backend like so: ```ts import { createServerFn } from "@tanstack/react-start";...
Solution:
//middleware to get the user and session and add them to the context app.use("*", async (c, next) => { const session = await auth.api.getSession({ headers: c.req.raw.headers }); if (!session) {...

Social Sign-on - Google - scope out image?

Hello, is there a way to scope OUT of google authentication the gmail profile image? In other words, I dont want to port over the gmail avatar into my user instance. How could I disactivate such? thanks!...

Authorize User or Session in Separate Hono Server but Better-Auth is in Nextjs

I have a nextjs app setup with better-auth. I have a separate server, but I need to authorize and get the user in my hono server. How would I do it? As http cookies are not sent over other domains. Please help.

Help with Keystone 6 express backend framework

I am using a headless cms called Keystone and I am simply trying to hook up better-auth to the express side of it. I am unable to reach all /api/auth/* endpoints but I am able to access /api/auth/callback which gives me a Better Auth error with Error code state_not_found. Any ideas? Any help will be appreciated 🙏🏾...

better-auth/client internal fetch logic gets overridden or ignored

Hey team 👋 — I'm using better-auth/vue in my Nuxt 3 app to call my custom backend API. When I pass a baseURL to createAuthClient, it seems like all the internal fetch logic (like headers, payload serialization, etc.) gets overridden or ignored. Here's my usage:...

Timeout when deploying to Cloudflare Workers with Better Auth when using getSession

Hiya 👋 I'm deploying a React Router v7 application to Cloudflare Workers, using Better Auth and Drizzle ORM. My issue is that the Worker fails validation due to exceeding a startup limit....

How to show this menu when signing in with Google?

Right now, when I login with google it just logs me in to the first email directly. I would like the ability to sign in with other accounts.
Solution:
Figured it out Added this to auth.ts ```ts socialProviders: { google: {...
No description

Additional field validation

@Ping I'm using additional fields. I want it so the user can input this (it's a bio field), is it possible to enforce restrictions here? Eg min/max length. Or need I create my own backend endpoint to sanitize it? ```...

Using secure cookies on local dev server (running https) not working

I am need to test my application locally using https for a third party integration (unrelated to this), but I am running into an issue where my sessions are not being found after sign-in when using a local https server, using secure tokens. I tried to set the advanced useSecureCookies config to true, but that did not work. The secure cookies are being set in my browser, the sessions exist in the database, and the tokens that I am logging on the console are all lining up, however when I use the getSession hook, its returning null. Debuggin items I have checked: - BETTER_AUTH_URL is being set to https://localhost:3000...

legal-consent plugin not extending authClient.signUp.email

Hi all! Just getting to know the plugin ecosystem of better-auth and I must say I am very happy with better-auth so far! When using the legal-consent plugin I have hit a snag, it doesn't seem like it's extending the auth client properly and thus won't pass the tosAccepted and privacyPolicyAccepted fields through to the database resulting in DB errors due to a missing field....
No description

[Stripe] Annual or Monthly in getCheckoutSessionParams?

I want to change getCheckoutSessionParams depending on if it is an annual or monthly subscription. I don't find any option on how to get that information.

is a passwordless sign-up/sign-in possible?

im trying to roll out passwordless login with email otp (similar to that of supabase), which can sign up users if they don't exist in the db or sign in, however im getting the following error:
TRPCClientError: [# Drizzle Adapter]: The model "verification" was not found in the schema object. Please pass the schema directly to the adapter options.
TRPCClientError: [# Drizzle Adapter]: The model "verification" was not found in the schema object. Please pass the schema directly to the adapter options.
^^^ the verification table exists in my db with the exact schema generated by the cli (check image)...
No description

How do I validate sessions / access in my backend

Am I correct to assume that I need to query the db based off the access token provided to verify if the request is legit, or is there an api that I can use to do this built-in to better-auth? My backend api is made in C# using ASP.NET core, so I need to protect certain routes which is why im asking....

svelte-kit-example not working

I followed the instructions, but I had to move the whole example outside of the workspace to install the dependencies and then i had to install better-auth from npm rather than the workspace (obvs). But then it won't run still "Button" is not defined. Confused ......