#Better Auth

18 messages · Page 1 of 1 (latest)

vague vault
#

I am trying to integrate Better-auth as part of my current payload application. any tutorials on how to do this easily?

sharp fernBOT
vague vault
#

Any ideas if I can apply it to a custom Collection? Not 'users'?

golden agate
karmic solstice
golden agate
heavy swift
# karmic solstice Hey, by any chance did you try to use better-auth in a separate collection (like...

This seems to be the preferred approach my most people. I found this plugin, Auth-Smith, that handles it like in a separate collection but I don't think it uses better-auth, I believe they rolled their own.

https://github.com/authsmith/payload-auth-plugin

I havent tried either yet, but I'm also looking for a better-auth solution.

GitHub

Authentication plugin for Payload CMS. Contribute to authsmith/payload-auth-plugin development by creating an account on GitHub.

vague vault
#

Thanks to @quiet osprey and his great work - managed to get it working perfectly.

sharp fernBOT
heavy swift
vague vault
#

What u having issue with?

heavy swift
#

Nothing in particular really as I havent started, but if you were having an issue it would be helpful to know what the issue was and how you solved it.

#

That being said, if I do get into an issue ill report back

quiet osprey
#

The plugin does alot of heavy lifting for the most part, you just need to configure the settings correctly.

All the options are typed with some type docs on them. So just reading there can help, but otherwise any specific questions you can always drop here, to me personally or just in the GitHub repository through bugs or issues.

I do my best to answer/ respond, merge prs and maintain the plugin.

As it’s also something I wrote to use personally in production projects.

heavy swift
#

Oh hey! I dont want to Hijack this thread do Ill DM

past dragon
#

I tried the starter but ran into issues when using a custom genericOAuth provider where it is not finding the endpoint it redirect backs to.

https://github.com/fluid-design-io/payload-better-auth-starter/

POST /api/auth/sign-in/oauth2

POST /api/auth/oauth2/callback/AzureAD 404 in 15ms.

I'm not sure how I can verify that the endpoint it is trying to hit is properly configured but as far as I understand it should look like the above if the providerName is AzureAD.

I tred a few things in the app/api/auth/[...all] endpoint but had the same problem regardless.

import { auth } from '@/lib/auth';

import { toNextJsHandler } from 'better-auth/next-js';

// const payload = await getPayload()

// export const { POST, GET } = toNextJsHandler(payload.betterAuth)

export const { POST, GET } = toNextJsHandler(auth.handler);

Answer POST is not supported for default oauth providers and I had to change the config to responseMode: "query",
https://github.com/better-auth/better-auth/issues/4327

tepid hazel
#

I understand SSO is some part of Payload monetization system, but auth is so basic today! I reaaaaally like Payload, but this lack of support for basic auth, is what sometimes makes me think on not using it. Payload is amazing, I think that would unlock this project to be widely adopted for everyone wanting to build Startups, which is our case.