Roblox
获取你的 Roblox 凭证
从 Roblox 创作者中心 获取你的 Roblox 凭证。
确保将重定向 URL 设置为 http://localhost:3000/api/auth/callback/roblox 用于本地开发。对于生产环境,你应该将其设置为你的应用的 URL。如果你更改了认证路由的基础路径,你也应该相应地更新重定向 URL。
Roblox API 不提供电子邮件地址。作为一种变通方法,用户的 email 字段使用 preferred_username 值代替。
配置提供程序
要配置提供程序,你需要导入该提供程序并将其传递给身份验证实例的 socialProviders 选项。
import { betterAuth } from "better-auth"
export const auth = betterAuth({
socialProviders: {
roblox: {
clientId: process.env.ROBLOX_CLIENT_ID as string,
clientSecret: process.env.ROBLOX_CLIENT_SECRET as string,
},
},
})Sign In with Roblox
To sign in with Roblox, you can use the signIn.social function provided by the client. The signIn function takes an object with the following properties:
provider: The provider to use. It should be set toroblox.
import { createAuthClient } from "better-auth/client"
const authClient = createAuthClient()
const signIn = async () => {
const data = await authClient.signIn.social({
provider: "roblox"
})
}