Better Auth

BA

Better Auth

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

Join

bug-reports

help

Anonymous users cannot sign in again anonymously... but you can?

When you authClient.signIn.anonymous() while already having an anonymous session, you get a bad request error. This is intentional of course. However, a new anonymous user is still created, with a session, and the better-auth.session_token cookie is also updated. So either, the 400 error is nonsense because everything works properly. Or, the error is correct but all the logic is still executed. ...

"superadmin" to bypass organization membership checks

Hey all, I'm working with better-auth and have noticed all of the organization methods check that the acting user is a member of that org first. This to me is an issue, as if the user is an admin/has valid permissions I want them to be able to act against orgs without them being a member - https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/organization/routes/crud-invites.ts#L180 Can we better leverage perms here as a feature request?...

Organization management for platform admins?

Hi, Is there a way to manage the organizations in the system much like with the admin plugin? I mean a platform administrator on the client-side lists and manages all the available organizations? Are there any plans to extend the admin plugin to work over the organizations and other entities/plugins (e.g: sso-providers)?...

onboarding wizard: handle custom fields on session and caching session

hi. i'm a new nextjs dev and interested in using better auth in this project. im currently have trouble understanding and finding solution about session. here is what i want to achieve: - when the app is freshly build, there will be a default superadmin account (i implement my own role management, not using the admin or organization plugin) - when superadmin login, user need to do a first setup wizard. and when this setup is not completed, we cant access any route until setup is completed problem:...

How to scope MCP access tokens to a specific organization?

Hello! I am using both the Organization and the MCP plugins. I would like my MCP access tokens to be scoped to a specific organization and not give access to all organizations of a user. The flow I was envisioning is to have the user login if not already the case, then go to org selection page before the authorization was done, but couldn't find how to achieve this. ...

Passkey check

hello there... how would i check either user device/browser has registerd passkey

How to Retrieve Session in Next.js RSC Without Getting 401 (Next.js + Hono Integration)

Hi, I'm building a full-stack app using Next.js for the frontend and Hono.js for the backend, running on separate ports in development (localhost:3000 for Next.js and localhost:8787 for the Hono server with Better Auth). I’m using the following logic on the client side to get the current user:...

Issues signing in with SSO

Hello. I register my SSO Provider using the OIDC config in the authClient.sso.register function, and I get the data stored in the database in the format of ```json { "_id": { "$oid": "688132034fd131f8a55b9c4a" },...

Session is set to www domain

How do I fix this? I need the cookie to work for either www.domain.com or the domain.com as well. I know how to do it in normal sessions but don't know how to set this in better auth

Custom JWKS endpoint?

Hi, I've been integrating a provider (Web3Auth) and they only provide a JWKS endpoint where they return an identity token, no token/discovery/userinfo endpoints, does better-auth supports that? Seems like the generic auth kinda works with it but I can't find a way of providing a custom JWKS endpoint instead of the discovery URL.

Polar plugin

Hey! So I am trying to use the better auth polar plugin but when I try to do the customer portal, I get this error. Any idea why this happens, am I doing something wrong?
No description

Multisession orgs list for diffrent accounts

docs : https://www.better-auth.com/docs/plugins/multi-session Here how can i see only the orgs of the account it belongs to . Means currently the list is listing orgs from the active session account by default . Btw am using multisession and cant find any onbuild way of doing it ....
No description

OIDC Provider: "No database configuration provided" and plugin not loaded on Vercel

Hi! I’m trying to use the OIDC Provider plugin with Better Auth on a Next.js (App Router) project deployed on Vercel. My DATABASE_URL and BETTER_AUTH_SECRET environment variables are correctly set (I can see them in my logs). My lib/auth.ts config looks like this: ```...

Allow user to edit their own data

Hi! I've defined some custom permissions in my application, which include the roles: admin, manager, and viewer. In my current setup:...

OAuth organization integrations

Can better-auth be used to add authentications for an org (e.g. what Discord calls Integrations in Server settings)? For SaaS apps I often want to separate user login (accounts the user can sign in with) from connecting integrations (the app performs operations on behalf of the org in a 3rd party system, e.g. post a tweet). My idea was to store Organization->Integrations in a similar way as User->Accounts. Is there a better-auth function I can call to trigger OAuth from an organization context b...

How can I know more about the invalid_client Error Code?

I'm integrating the MCP plugin to my tanstack start app, I swear yesterday it was working but today I always get that invalid_client right after a successful login. I don't know where to look at, maybe a vscode update (I'm on the insiders with daily updates) or really I don't understand why it suddently stopped working. Regardless of yesterday vs today, back do the initial question, where can I know more about the invalid_client error?...
Solution:
That's great, I had deleted the oauth_application entry on my db that was generated by vscode the first time, without telling vscode to also remove it from its cache. From vscode I ran the command "Remove Dynamic Authentication Provider" and tried again my MCP server, it did again the discovery process and it know works 😄...
No description

Customizing schema is not working in client side.

Docs i have refered : https://www.better-auth.com/docs/plugins/organization#customizing-the-schema I have auth.ts and auth-client.ts , Organisation plugin from my auth.ts looks like this (as file ) and in auth-client.ts ...
No description

disableCookieCache: it doesn't refresh the cookie cache

I have a page where I have to set active organization and active team when the user goes. In auth configuration the session cookieCache is enabled and maxAge is 300. After setting the active organization and active team, I'm getting the refreshed session by using disableCookieCache: true, and log the session and I can see the active org and active team, so far so good. But when I refresh the page, the page again sets the active organization and active team because session data in cookie is not refreshed. It still has empty active org and active team. Based on doc (https://www.better-auth.com/docs/concepts/session-management#session-caching), it says disableCookieCache: true will refresh the cookie cache, but it doesn't. Am I missing a point here?...

api.auth.getSession returns null

Better auth team. Can you fix this issue? This is really bugging my application. https://github.com/better-auth/better-auth/issues/2055...

MCP Plugin not working with MCP Inspector

Hello When running the official https://github.com/modelcontextprotocol/inspector for authentication, it is sending an OPTIONS request to the oauth registration endpoint (http://localhost:5173/api/auth/mcp/register), which is not defined by the plugin and returns a 404. On the inspector, this ends the signin flow and it's not possible to use the inspector I also noticed that the plugin is not defining a .well-known/oauth-protected-resource route, which the MCP clients are querying...