三個步驟即可開始
建立應用程式
在開發者主控台中註冊一個 OAuth 用戶端。立即取得你的 client_id 與 client_secret。
安裝 SDK
npm install @uniauth/js 或 @uniauth/react。也可透過 uniauth.id/sdk/ 的 CDN 取得。已內含 TypeScript 型別。
加入登入按鈕
呼叫 login(),UniAuth 便會處理 OIDC 流程、PKCE、權杖更新與登出。你會取得一個使用者物件。
簡單整合
三個 SDK,一套 OAuth 流程。下方每個示範都可實際操作──點擊按鈕即可試用彈出式驗證流程。
Live demo — simulated OAuth flow
The widget renders a branded button and handles the full PKCE flow.
<script src="https://uniauth.id/brand/oauth/uniauth-widget.js"></script>
<div id="signin"></div>
<script>
UniAuth.renderButton('#signin', {
clientId: 'YOUR_CLIENT_ID',
redirectUri: window.location.origin + '/callback',
mode: 'popup', // or 'redirect', or omit for auto
theme: 'dark',
onSuccess: function(result) {
console.log('Token:', result.accessToken);
},
onError: function(err) {
console.error(err);
}
});
</script>完整的 API 涵蓋範圍
OIDC 探索
可透過 .well-known/openid-configuration 自動設定。公開所有端點、範圍與宣告。
權杖端點
支援授權碼、重新整理、用戶端憑證、裝置與權杖交換等授權類型。支援 DPoP。
UserInfo
依 OIDC Core 支援 GET + POST。依範圍劃分的宣告:profile、email、phone、address、groups。
JWKS
用於驗證 ID 權杖的 RS256 公開金鑰。具備含重疊期間的金鑰輪替。
動態註冊
RFC 7591 用戶端註冊。具速率限制、範圍白名單,並提供 registration_access_token。
Webhook
經 HMAC 簽章的即時事件:user.created、login、logout、password_changed、consent_granted。
裝置流程
適用於 CLI 工具、智慧電視與 IoT 的 RFC 8628。提供人類易讀的 XXXX-XXXX 代碼。
SCIM 2.0
Users + Groups 的 CRUD、Bulk 操作與篩選查詢。依組織範圍佈建。
管理 API
完整管理使用者、工作階段、用戶端、群組與政策。支援 GraphQL 與 REST。