Help with BETTER_AUTH_URL and Redirects for Server-Side Authentication in Figma Plugin
Hi everyone! I'm working on a Figma plugin and trying to handle authentication fully on the server-side using Better Auth. I've been running into some issues with the BETTER_AUTH_URL setting and the Google OAuth flow. Here's the situation:
1. Setting BETTER_AUTH_URL to the server URL (
How do I properly configure Better Auth so that the server handles the OAuth flow? 2. Changing BETTER_AUTH_URL to the client URL (
http://localhost:5000
):
- Since I want all authentication logic on the server side, I set BETTER_AUTH_URL=http://localhost:5000
in my .env
.
- However, when I try to authenticate with Google, I get the following error:
- [Insert error message here if you have one]
How do I properly configure Better Auth so that the server handles the OAuth flow? 2. Changing BETTER_AUTH_URL to the client URL (
http://localhost:3000
):
- When I set BETTER_AUTH_URL=http://localhost:3000
(the client side), the OAuth flow works up to a point, and I get redirected back to:
- But I want the callback to go to the server (localhost:5000
), so I manually change the callback URL to http://localhost:5000/api/auth/callback/google
.
3. Error after changing the callback URL:
- When I manually change the callback URL to point to the server (localhost:5000
), I end up getting redirected to http://localhost:3000/?error=account_not_linked
. This seems to break the authorization process, and it looks like the session isn't being linked properly.
My goal is to handle authentication entirely on the server side for my Figma plugin, that's why for understanding better auth i am trying this poc with react(next js).
But I'm struggling to set up the correct redirect and callback URLs. The user should interact with the server for all auth steps, and the client (Figma plugin) should just receive a response after authentication is complete.12 Replies
Key Details:
- Server URL:
http://localhost:5000
- Client URL: http://localhost:3000
- I'm using Google and GitHub OAuth providers, and account linking is enabled (accountLinking: { enabled: true, trustedProviders: ["google", "github"] }
).
- Here's my basic setup in case it helps:
- BETTER_AUTH_URL=http://localhost:5000
- My frontend tries to start the OAuth flow, but I want the server to handle the rest.
Does anyone know how I can properly configure Better Auth for server-side-only authentication and fix the account_not_linked
issue after the Google callback? Any advice would be greatly appreciated!github repo: https://github.com/jacksonkasi1/better-auth-example
GitHub
GitHub - jacksonkasi1/better-auth-example
Contribute to jacksonkasi1/better-auth-example development by creating an account on GitHub.
hey guys any one can plz guide me?
@bekacru Hey, sorry to bother you. I am stuck a bit. If I get some guidance, I will start applying this better auth in my Figma plugin.
https://github.com/jacksonkasi1/ImagePro-Export
GitHub
GitHub - jacksonkasi1/ImagePro-Export: Enhance your Figma image exp...
Enhance your Figma image export! Export PNG, JPG, SVG, PDF, customize file names, search filters, scale options, and light/dark mode. Download organized ZIPs by scale. Perfect for developers and de...
account_not_linked happens if the provider isn't trusted
Issue 1 & 2 were my silly mistakes. The 3rd issue still persists.
what is the 3rd issue?
it's about account_not_linked after login
@bekacru Just now, I am exploring better-auth. I still have to learn some concepts about making plugins.
I am just asking if itβs possible to create a plugin on client side to support Figma Plugin to support all/most social sign-ins? Is it possible?
Because I can't store cookies or sessions in the Figma plugin; it only allows storing data in
figma.clientStorage
. So Iβm asking.you can use the
bearer
plugin. Store the session id returned after a user signs in and send the session id as a bearer token on subsequent authed requests.thank you @bekacru, you save my life again π
@bekacru Thanks again π! Due to your support, I have finally done it.
