Dropbox
获取你的 Dropbox 凭证
要使用 Dropbox 登录,你需要一个客户端 ID 和客户端密钥。你可以从 Dropbox 开发者门户 获取它们。你可以在应用控制台中为应用允许“隐式授权 & PKCE”。
请确保在本地开发时将重定向 URL 设置为 http://localhost:3000/api/auth/callback/dropbox。在生产环境中,应将其设置为你应用的 URL。如果你更改了身份验证路由的基础路径,也应相应地更新重定向 URL。
如果你需要更深入了解 Dropbox 认证,可以查看官方文档。
配置提供程序
要配置提供程序,你需要导入该提供程序并将其传递给身份验证实例的 socialProviders 选项。
import { betterAuth } from "better-auth"
export const auth = betterAuth({
socialProviders: {
dropbox: {
clientId: process.env.DROPBOX_CLIENT_ID as string,
clientSecret: process.env.DROPBOX_CLIENT_SECRET as string,
},
},
})Sign In with Dropbox
To sign in with Dropbox, 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 todropbox.
import { createAuthClient } from "better-auth/client"
const authClient = createAuthClient()
const signIn = async () => {
const data = await authClient.signIn.social({
provider: "dropbox"
})
}