how to integrate non-oauth providers?

I'm implementing Telegram login which doesn't follow OAuth flow. After verifying the user's Telegram credentials and creating/finding the user in my database, what's the correct way to create a proper Better Auth session? I want to avoid false negatives when checking sessions in my middleware.
4 Replies
KiNFiSH
KiNFiSH2w ago
hmmm i dont think u will have a clear path for that since auth instance cant really access the internalAdapter for creating a session and user. so probably it is safe for you to implement a plugin for telegram auth to access internalaAdapter and do crud on user and session table.
KiNFiSH
KiNFiSH2w ago
and creating a plugin is so easy and it is also well documented - https://www.better-auth.com/docs/concepts/plugins
Plugins | Better Auth
Learn how to use plugins with Better Auth.
bkyerv
bkyervOP2w ago
@KINFISH still struggling. if I share repo with how I tried to implement it, would you have time to look at it?
KiNFiSH
KiNFiSH2w ago
ig the docs are pretty good on implementing your plugin. just go thru it and lemme know if you had any confusion

Did you find this page helpful?