快速开始
5 分钟内将 W-ID 集成到你的应用中。客户前端可以单独开发,只依赖公开 API、OAuth redirects、CORS 和 Cookie/Token 策略。
方式 A: 使用 SDK
<script src="/sdk/w-id.js"></script>
const auth = WID.init({
clientId: 'YOUR_CLIENT_ID',
redirectUri: window.location.origin + '/callback'
});
auth.login();
await auth.handleCallback();
pub(crate) const user = await auth.getUser();
方式 B: 使用 JSON Auth API
const config = await fetch('/api/auth/config', { credentials: 'include' }).then(r => r.json());
await fetch(config.endpoints.login, {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
方式 C: 手动 OAuth
GET /oauth/authorize?client_id=YOUR_ID&response_type=code&redirect_uri=YOUR_CALLBACK&scope=openid%20email%20profile
POST /oauth/token
GET /oauth/userinfo
方式 D: 同步 Radar
为 Workspace 里的 OAuth Client 接入 Radar,请查看 Radar 接入。Radar 项目对应具体 OAuth Client,Workspace 只作为团队/租户边界。