# Naver (/docs/authentication/naver)

Naver 提供者的设置和使用。



<Steps>
  <Step>
    ### 获取 Naver 凭证 [#获取-naver-凭证]

    要使用 Naver 登录，您需要客户端 ID 和客户端密钥。您可以从 [Naver 开发者平台](https://developers.naver.com/) 获取它们。

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

  <Step>
    ### 配置提供者 [#配置提供者]

    要配置提供者，您需要导入该提供者，并将其传递给认证实例的 `socialProviders` 选项。

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

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

  <Step>
    ### 使用 Naver 登录 [#使用-naver-登录]

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

    * `provider`：要使用的提供者，应设置为 `naver`。

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

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

