AI 原生 BaaS 平台 Supabase 版
API 类型 | 使用者 | 作用 | 方式及示例 |
API 类型 | 使用者 | 作用 | 方式及示例 |
Admin API | 应用(APP)开发者 | 配置 Auth 相关参数 |
# 查询配置 curl -X GET $SUPABASE_BASE_URL/auth/v1/config \ -H "apikey: ${SERVICE_ROLE_KEY}" \ -H "Authorization: Bearer ${SERVICE_ROLE_KEY}" \ -H "Content-Type: application/json"
curl -X PATCH $SUPABASE_BASE_URL/auth/v1/config \ -H "apikey: ${SERVICE_ROLE_KEY}" \ -H "Authorization: Bearer ${SERVICE_ROLE_KEY}" \ -H "Content-Type: application/json" \ -d '{ "SMTP_HOST": "smtp.qq.com", "SMTP_USER": "test-user", "SMTP_PASS": "test-paas" }' |
Client API ( Supabase Client SDK) | 应用(APP)使用者 | 在 APP 前端中访问 auth(注册、登录等) |
import { createClient } from '@supabase/supabase-js' const supabase = createClient( "<SUPABASE_BASE_URL>", "<SUPABASE_ANON_KEY>") // 邮箱注册 async function signUp() { const { data, error } = await supabase.auth.signUp({ email: 'user@example.com', password: 'password123' }) if (error) { console.log('注册失败:', error.message) return } console.log('注册成功,请查收邮箱验证', data) }
import { createClient } from '@supabase/supabase-js' const supabase = createClient( "<SUPABASE_BASE_URL>", "<SUPABASE_ANON_KEY>") // 账号密码登录 async function signIn() { const { data, error } = await supabase.auth.signInWithPassword({ email: 'user@example.com', password: 'password123' }) if (error) { console.log('登录失败:', error.message) return } console.log('登录成功', data.user) } |