This guide will walk you through integrating Universal Verify into your application. We'll cover account setup, SDK installation, and implementing the OAuth flow.
verification
, openid
age
legal_name
, date_of_birth
, id_type
Install via npm:
npm install universal-verify-js
Or use via CDN:
import FrontendSDK from 'https://cdn.jsdelivr.net/npm/universal-verify-js@0.0.2/build/universal-verify.min.js';
Install via npm:
npm install universal-verify
// Frontend
const frontendSDK = new FrontendSDK(apiKey);
// Backend
const backendSDK = new BackendSDK(apiKey, apiSecret);
const { codeChallenge, codeVerifier } = await backendSDK.createCodeChallenge();
// Send codeChallenge to frontend
const authUrl = frontendSDK.createAuthorizationUrl({
codeChallenge: codeChallenge,
redirectUrl: 'https://your-app.com/callback',
scope: 'verification openid age', // Optional
state: 'your-state', // Optional
nonce: 'your-nonce' // Optional
});
window.location.href = authUrl;
const { code, state } = frontendSDK.parseRedirectUrl();
// Send code to backend
const {
access_token,
refresh_token,
id_token,
expires_in,
scope,
sub,
token_type
} = await backendSDK.exchangeCodeForTokens({
code: code,
codeVerifier: codeVerifier,
redirectUrl: 'https://your-app.com/callback'
});
const userInfo = await backendSDK.getUserInfo(access_token);
// userInfo contains: sub, verified, verification_confidence, age (if requested)
// For sensitive scopes, get additional regional info
if (userInfo.regional_info) {
const regionalUserInfo = await backendSDK.getRegionalUserInfo(
access_token,
userInfo.regional_info.additional_userinfo_url
);
}
const tokenClaims = await backendSDK.validateIdToken(id_token, nonce);
const { access_token, refresh_token } = await backendSDK.refreshToken(refresh_token);