用途:为使用 @cloudbase/js-sdk@2.24.0+ 的 Web 前端项目提供用户认证方案,兼容 supabase-js API。
前置条件:需要 CloudBase 环境 ID(env)与 Region(region);需先通过 auth-tool-cloudbase 获取 publishable key 并配置登录方式。若该工具失败,可前往 https://tcb.cloud.tencent.com/dev?envId={env}#/env/apikey 获取 publishable key,并在 https://tcb.cloud.tencent.com/dev?envId={env}#/identity/login-manage 设置登录方式。
初始化:使用 cloudbase.init 传入 env、region(默认 ap-shanghai)、accessKey(publishable key)及 auth: { detectSessionInUrl: true },再取 app.auth。CDN 源:https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js
主要能力:支持手机 OTP(推荐)、邮箱 OTP、密码、注册(仅邮箱与手机 OTP,存在则自动登录)、匿名、OAuth(Google/WeChat)、自定义 Ticket、匿名升级;用户管理含登出、获取/更新用户、改密、重置密码、绑定/解绑第三方、删除账号、监听状态变化、获取 access token、刷新用户。
使用方式:调用 auth.signInWithOtp、verifyOtp、signInWithPassword、signUp、signInAnonymously、signInWithOAuth、signInWithCustomTicket 等方法;微信小程序可用 signInWithOpenId、signInWithPhoneAuth。
限制:注册仅支持邮箱与手机 OTP;更新邮箱或手机需 verifyOtp;部分登录方式需先在控制台开启。具体收费、价格与效果资料未提供。