Exploring Better Auth SSO Plugin – Guidance on authClient.sso.register Usage

I’ve created a sample repository to explore the usage of the Better Auth SSO plugin. While working on it, I was unsure about the appropriate placement and timing for calling authClient.sso.register, especially since invoking this API requires an active user session. Additionally, there is no implementation provided for signInWithTestUser, which added to the confusion. Documentation reference: Better Auth SSO Plugin - Register an OIDC Provider It's worth noting that sensitive information such as clientId and clientSecret should be handled exclusively on the backend. Sample repo: https://github.com/amal-chandran/sso-better-auth If anyone has a production-ready example or further guidance on implementing this correctly, I’d greatly appreciate it!
Single Sign-On (SSO) | Better Auth
Integrate Single Sign-On (SSO) with your application.
Solution:
so the sso plugin is meant to be used by allowing users to register a custom provider that can be used later to authenticate user
Jump to solution
5 Replies
Solution
bekacru
bekacru2w ago
so the sso plugin is meant to be used by allowing users to register a custom provider that can be used later to authenticate user
bekacru
bekacru2w ago
If you need a set of pre-defined providers checkout the generic oauth plugin instead
Amal Chandran
Amal ChandranOP2w ago
Ok, thanks for the clarification. It would be great if you can add the same in docs as well
Bazza
Bazza2w ago
Hey @Amal Chandran, do you still have an example repository perhaps? I'm working on a side project where i try to use Keycloak as my Auth Server. Would be nice to see an example implementation as a template. I much appreciate your help. Thanks and all the best
Amal Chandran
Amal ChandranOP6d ago
@Bazza This was my use-case app-one is the primary platform where users authenticate using their credentials. app-two is a secondary service that users need to access. To improve user experience and security, a Single Sign-On (SSO) mechanism is required so that users already logged into app-one can access app-two without being prompted for credentials again. This is the example repo https://github.com/amal-chandran/sso-better-auth If you check the above comment you can see for my use case i should have used https://www.better-auth.com/docs/concepts/oauth Insted of https://www.better-auth.com/docs/plugins/sso So my approch is not correct for the use case. The main reason for me to create the above repo is for reporting the issue below https://github.com/better-auth/better-auth/issues/2360
OAuth | Better Auth
How Better Auth handles OAuth
Single Sign-On (SSO) | Better Auth
Integrate Single Sign-On (SSO) with your application.
GitHub
Invalid scope error even after setting scopes array · Issue #2360 ...
Is this suited for github? Yes, this is suited for github To Reproduce Clone the repo and run the app as mentioned in readme https://github.com/amal-chandran/sso-better-auth Current vs. Expected be...

Did you find this page helpful?