Is there any way to pass any flag to CTX (like query, param, body, etc...) in Google Oauth
I am trying to create the mechanism of organization invites and when the user is invited I have the invitation token I want to pass it in ctx so I can use it in my database hook, with email and pass signup I was able to send it in ctx.params but on Google signIn I am not being able to pass it, how can I achieve this?
I have tried the onRequest and onSuccess and I was not yet able to do it

8 Replies
Saw this thread that I think is the same issue: https://www.answeroverflow.com/m/1356698055113572372
Anything changed since this?
Social login Account creation with additional field - Better Auth
How to pass additional state during a social provider sign-in (e.g., Google). When a new user signs up with say for example Google, I want to store an extra field in the database, like { "a": "123" }, alongside the default user data. How can I pass this custom data from the client and handle it on the server to save it in the DB?
``` const sig...
@admin if any of you can give me here a hand would appreciate
You can either add data to your database before hand, then verify it's the same device that logged in via oauth to assign those new values to their account, or you can pass it via something like query params in the
callback
of your signIn.oauth if it's not needed to be a secure value, then assign that value to the userBy passing on the callback do i have access on the ctx on the database hook?
I think so, but not 100%. Let me test it.
Thanks, keep me posted
Okay I was wrong. This is very tricky given how Better Auth doesn't currently support additional fields during oauth signup. I've mentioned it to the team to maybe see why we don't already have this and maybe work towards it, but for now I think you will have to use workarounds such as having a page dedicated to oauth signed up accounts to update user data or something along those lines
Yeah ended up going with cookies and getting it on the callback page
Would be cool to have something more elegant for the future
Thanks for the help