# Roblox (/docs/authentication/roblox)

Roblox 提供程序的设置和使用。



<Steps>
  <Step>
    ### 获取 Roblox 凭证 [#获取-roblox-凭证]

    从 [Roblox Creator Hub](https://create.roblox.com/dashboard/credentials?activeTab=OAuthTab) 获取 Roblox 凭证。

    请确保将重定向 URL 设置为 `http://localhost:3000/api/auth/callback/roblox` 用于本地开发。在生产环境中，应将其设置为应用程序的 URL。如果更改了认证路由的基本路径，需要相应地更新重定向 URL。

    <Callout type="info">
      Roblox API 不提供电子邮件地址。Better Auth 使用用户稳定的 `sub` 声明创建一个不可路由的 `{sub}@roblox.placeholder.invalid` 地址。
    </Callout>
  </Step>

  <Step>
    ### 配置提供程序 [#配置提供程序]

    要配置提供程序，需要导入提供程序并将其传递给 `socialProviders` 选项。

    ```ts title="auth.ts"  
    import { betterAuth } from "better-auth" 

    export const auth = betterAuth({
        socialProviders: {
            roblox: { // [!code highlight]
                clientId: process.env.ROBLOX_CLIENT_ID as string, // [!code highlight]
                clientSecret: process.env.ROBLOX_CLIENT_SECRET as string, // [!code highlight]
            }, // [!code highlight]
        },
    })
    ```
  </Step>

  <Step>
    ### 使用 Roblox 登录 [#使用-roblox-登录]

    要使用 Roblox 登录，可以使用客户端提供的 `signIn.social` 函数。`signIn` 函数接收一个包含以下属性的对象：

    * `provider`: 要使用的提供程序，应设置为 `roblox`。

    ```ts title="auth-client.ts"  
    import { createAuthClient } from "better-auth/client"
    const authClient =  createAuthClient()

    const signIn = async () => {
        const data = await authClient.signIn.social({
            provider: "roblox"
        })
    }
    ```
  </Step>
</Steps>

