Zoom

Zoom 提供者的设置和使用。

从 Marketplace 创建 Zoom 应用

  1. 访问 Zoom Marketplace。

  2. 将鼠标悬停在 Develop 按钮上并选择 Build App

  3. 选择 General App 并点击 Create

配置你的 Zoom 应用

确保你位于应用设置的 Basic Information 页面。

  1. 在 Select how the app is managed 中,选择 User-managed

  2. 在 App Credentials 下,复制你的 Client ID 和 Client Secret 并存储在安全的位置

  3. 在 OAuth Information -> OAuth Redirect URL 中,添加你的回调 URL。例如,

    http://localhost:3000/api/auth/callback/zoom

    对于生产环境,你应该将其设置为应用程序的 URL。如果更改了认证路由的基本路径,你需要相应地更新重定向 URL。

转到 Scopes 部分,然后

  1. 点击 Add Scopes 按钮
  2. 搜索 user:read:user(查看用户)并选择它
  3. 添加应用程序需要的其他范围并点击 Done

配置提供者

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

auth.ts
import { betterAuth } from "better-auth"

export const auth = betterAuth({
  socialProviders: {
    zoom: { 
      clientId: process.env.ZOOM_CLIENT_ID as string, 
      clientSecret: process.env.ZOOM_CLIENT_SECRET as string, 
    }, 
  },
})

使用 Zoom 登录

要使用 Zoom 登录,你可以使用客户端提供的 signIn.social 函数。 你需要将 zoom 指定为提供者。

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

const signIn = async () => {
  const data = await authClient.signIn.social({
    provider: "zoom"
  })
}