KiNFiSH
KiNFiSH
BABetter Auth
Created by Ashwanee Kumar Gupta on 4/27/2025 in #help
updateAccountOnSignIn
one thing you can work with db hooks also if your usecase actually works with the mapToUserProfile - you can use that -
plugins: [
genericOAuth({
config: [{
providerId: "your-provider",
clientId: "your-client-id",
clientSecret: "your-client-secret",
mapProfileToUser: async (profile) => {
return {
// Map other user fields
role: profile.role || "default-role" // Set the role from the provider's profile
};
}
}]
})
]
plugins: [
genericOAuth({
config: [{
providerId: "your-provider",
clientId: "your-client-id",
clientSecret: "your-client-secret",
mapProfileToUser: async (profile) => {
return {
// Map other user fields
role: profile.role || "default-role" // Set the role from the provider's profile
};
}
}]
})
]
4 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
Yeah but all this stuff is encapsulated by better auth on the methods from the ctx
12 replies
BABetter Auth
Created by Mattèo on 4/27/2025 in #help
How to handle phoneNumber.sendOtp errors ? Only 500 is returned
Can't you do it on the client side like if you want to check for malformed and if you received 500 make sure to run the client side logic. Since we get the custom phoneValidator or run the general fallback for that and return if that's fails with 500
5 replies
BABetter Auth
Created by Sami on 4/27/2025 in #help
is BETTER_AUTH_SECRET safe to expose on the client?
It should be used on the server it is used to sign secure things
2 replies
BABetter Auth
Created by chris_st on 4/20/2025 in #help
The table `main.verification` does not exist in the current database.
Did you see your tables existed after the push ?
15 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
Have you tried to use ctx object to set the cookie ?
12 replies
BABetter Auth
Created by Frank! on 4/25/2025 in #help
inferAdditionalFields
you will do manually for the client auth instance not the server.
7 replies
BABetter Auth
Created by Frank! on 4/25/2025 in #help
inferAdditionalFields
If your client and server are in separate projects, you'll need to manually specify the additional fields when creating the auth client.
7 replies
BABetter Auth
Created by Dustin on 4/25/2025 in #help
Extending the Organization plugin
currently we dont have a built in way of extending plugins but such you can make sure to run custom fn for some callbacks provided in addition if hooks may help make sure to use that as well for your usecase but it gonna be bloat on that
7 replies
BABetter Auth
Created by Jakub Hašek on 4/25/2025 in #help
Notion OAuth in Remix
i guess the error seems to be around validating the code during the flow .. i mean the code generated may not be matchin the code coming from on the query. so make sure to check state on your table and the code you get back from the oauth server
3 replies
BABetter Auth
Created by Dustin on 4/25/2025 in #help
Extending the Organization plugin
for extending i guess you can do a plugin by just copying the already existing org and team plugins and add those features seems to be safe way of doing it. but this is also something to think about. so feel free to try it out and let us the know the progress you made.
7 replies
BABetter Auth
Created by cupskrrtt on 4/22/2025 in #help
Get google oauth access token and implement google refresh token
if you use your authClient for calling to authClient.refreshToken()
9 replies
BABetter Auth
Created by cupskrrtt on 4/22/2025 in #help
Get google oauth access token and implement google refresh token
for the accessToken , it is stored on account Table along with refreshToken. you can use the internalAdapter for findAccount and get the access token for there . if you could get an access to ctx you can do this way
// this is by userID
const result = await ctx.context.internalAdapter.findAccounts(userId)

// this is by accountID
const result = await ctx.context.internalAdapter.findAccount(accountId)
// this is by userID
const result = await ctx.context.internalAdapter.findAccounts(userId)

// this is by accountID
const result = await ctx.context.internalAdapter.findAccount(accountId)
yeah for the refresh token , you can lets say i used twitter, i can do sth like this .. the url might not correct but you can pass your way of refreshing access token.
twitter: {
clientId: process.env.TWITTER_CLIENT_ID || "",
clientSecret: process.env.TWITTER_CLIENT_SECRET || "",
async refreshAccessToken(refreshToken) {
const response = await fetch("https://api.twitter.com/2/oauth2/token", {
method: "POST",
body: new URLSearchParams({
grant_type: "refresh_token",
refresh_token: refreshToken,
}),
});
const data = await response.json();
return {
accessToken: data.access_token,
refreshToken: data.refresh_token,
};
},
},
twitter: {
clientId: process.env.TWITTER_CLIENT_ID || "",
clientSecret: process.env.TWITTER_CLIENT_SECRET || "",
async refreshAccessToken(refreshToken) {
const response = await fetch("https://api.twitter.com/2/oauth2/token", {
method: "POST",
body: new URLSearchParams({
grant_type: "refresh_token",
refresh_token: refreshToken,
}),
});
const data = await response.json();
return {
accessToken: data.access_token,
refreshToken: data.refresh_token,
};
},
},
9 replies
BABetter Auth
Created by DN_Dev on 4/23/2025 in #help
Session Caching with Custom Fields Workaround
what was your usecase for caching may be i can navigate you around ?
13 replies
BABetter Auth
Created by Filippo on 4/23/2025 in #help
How to log in from the server
yeah the thing you are running the function and make sure it sending the correct setCookie headers and you can levarage more if you enabled cookieCache to not be able to ping the db for getting the session
12 replies
BABetter Auth
Created by Kasszz on 4/13/2025 in #help
Adding custom properties to Organization members
First add it there and try to infer the type by using the link above and try to mutate data based on that .
10 replies
BABetter Auth
Created by Kasszz on 4/13/2025 in #help
Adding custom properties to Organization members
It is extendible I mean the additionalField can also work with organization table it is not limited for a specific table. you should tweak some stuff manually for that tho
10 replies
BABetter Auth
Created by omero on 4/23/2025 in #help
How can I do multiple Database calls 'during' user creation transaction in google OAuth?
send it over
9 replies
BABetter Auth
Created by omero on 4/23/2025 in #help
How can I do multiple Database calls 'during' user creation transaction in google OAuth?
yeah that is another way of hooking in to flow.
9 replies
BABetter Auth
Created by Stephen on 4/23/2025 in #help
How to handle this error myself?
you can handle like this -
export const auth = betterAuth({
onAPIError: {
throw: true,
onError: (error, ctx) => {
// Custom error handling
console.error("Auth error:", error);
},
errorURL: "/auth/error"
},
})
export const auth = betterAuth({
onAPIError: {
throw: true,
onError: (error, ctx) => {
// Custom error handling
console.error("Auth error:", error);
},
errorURL: "/auth/error"
},
})
2 replies