Figma
获取你的凭证
- 登录你的 Figma 账户并访问 开发者应用页面
- 点击 “创建新应用”
- 填写应用详细信息(名称、描述等)
- 配置重定向 URI(例如,
https://yourdomain.com/api/auth/callback/figma) - 记录你的客户端 ID 和客户端密钥
默认范围是 current_user:read。有关 file_content:read 等其他范围,请参阅 Figma OAuth范围文档。
确保将重定向 URI 设置为与你的应用回调 URL 相匹配。如果你更改了认证路由的基本路径,应相应地更新重定向 URI。
配置提供程序
要配置提供程序,你需要导入该提供程序并将其传递给身份验证实例的 socialProviders 选项。
import { betterAuth } from "better-auth"
export const auth = betterAuth({
socialProviders: {
figma: {
clientId: process.env.FIGMA_CLIENT_ID as string,
clientSecret: process.env.FIGMA_CLIENT_SECRET as string,
},
},
})Sign In with Figma
To sign in with Figma, 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 tofigma.
import { createAuthClient } from "better-auth/client"
const authClient = createAuthClient()
const signIn = async () => {
const data = await authClient.signIn.social({
provider: "figma"
})
}For more information about Figma's OAuth scopes and API capabilities, refer to the official Figma API documentation.