Calling signIn.social with extended field data.

So I've added an additional field on my user in my server side auth
user: {
additionalFields: {
username: {
type: "string",
required: true,
unique: true,
},
},
},
user: {
additionalFields: {
username: {
type: "string",
required: true,
unique: true,
},
},
},
The issue I'm running into now is once I try to sign in with OAuth, i.e.
const data = await authClient.signIn.social({
provider: "google",
callbackURL: "http://localhost:3000/dashboard",
});
const data = await authClient.signIn.social({
provider: "google",
callbackURL: "http://localhost:3000/dashboard",
});
The issue is I get an error because there is no field for the username now.
2025-02-27 23:11:39 2025-02-28T07:11:39.578Z ERROR [Better Auth]: error: null value in column "username" of relation "users" violates not-null constraint
2025-02-27 23:11:39 2025-02-28T07:11:39.578Z ERROR [Better Auth]: unable_to_create_user
2025-02-27 23:11:39 2025-02-28T07:11:39.578Z ERROR [Better Auth]: error: null value in column "username" of relation "users" violates not-null constraint
2025-02-27 23:11:39 2025-02-28T07:11:39.578Z ERROR [Better Auth]: unable_to_create_user
Is there any way to pass in additional/extended fields in social sign ins?
3 Replies
iPheNoMeNaL-oG
iPheNoMeNaL-oG2mo ago
Have you found a solution for this? I'm running into the same thing when I've added first/last name as additional fields.
javid
javid2mo ago
@iPheNoMeNaL-oG , you found the answer for this
saze
saze2mo ago
You could pass a default value in your auth config, then redirect users who authenticates via oauth to a profile page where they can set their username

Did you find this page helpful?