Roblox
Get your Roblox Credentials
Get your Roblox credentials from the Roblox Creator Hub.
Make sure to set the redirect URL to http://localhost:3000/api/auth/callback/roblox for local development. For production, you should set it to the URL of your application. If you change the base path of the auth routes, you should update the redirect URL accordingly.
The Roblox API does not provide email addresses. As a workaround, the user's email field uses the preferred_username value instead.
Configure the provider
To configure the provider, you need to import the provider and pass it to the social_providers option of the auth instance.
require "better_auth"
auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: ENV.fetch("BETTER_AUTH_URL", "http://localhost:3000"),
social_providers: {
roblox: BetterAuth::SocialProviders.roblox(
client_id: ENV.fetch("ROBLOX_CLIENT_ID"),
client_secret: ENV.fetch("ROBLOX_CLIENT_SECRET")
)
}
)Sign In with Roblox
To sign in with Roblox, call auth.api.sign_in_social on your Ruby auth instance. The endpoint body takes the following properties:
provider: The provider to use. It should be set toroblox.
response = auth.api.sign_in_social(
body: {
provider: "roblox",
callback_url: "/dashboard",
error_callback_url: "/login",
disable_redirect: true
}
)
redirect_url = response.fetch(:url)