Developers
Sign in with Idizer (SSO)
OpenID Connect authorization code flow with PKCE for public web apps — same model as Sign in with Google.
Overview
Need a phone input that detects Idizer mailboxes first? See Idizer phone field. This guide covers full SSO login.
Industry-standard OpenID Connect with Authorization Code + PKCE (S256) for public web apps — the same model as Sign in with Google. No client secret in the browser.
Quick start (recommended)
- Register redirect URI(s) under Account → Sign-in & SSO → Your SSO applications and wait for admin approval.
- Add the official embed on your login page and callback page (see Button preview) — script runs on your origin; PKCE state stays on your domain.
- On the callback page, check
stateand POST the code to your server. Your server exchanges it, verifies the ID token, and sets an httpOnly session cookie.
Authorization flow
- User clicks your login button on your domain.
- Browser redirects to
GET /oauth/authorizewithcode_challenge(S256). - User signs in with SMS (if needed) and sees the consent screen.
- If you requested the
emailscope, they pick their Idizer address or a verified linked email. - Idizer redirects back with
?code=…&state=…. - Your callback page checks
state, removes the code from the address bar, and POSTs the code, verifier, and nonce to your own server. - Your server posts to
POST /oauth/token, verifies the ID token with JWKS, then sets your session cookie.
Endpoints
| Purpose | URL |
|---|---|
| Discovery | http://localhost:3001/.well-known/openid-configuration |
| Authorize | http://localhost:3001/oauth/authorize |
| Token | http://localhost:3001/oauth/token |
| UserInfo | http://localhost:3001/oauth/userinfo |
| JWKS | http://localhost:3001/.well-known/jwks.json |
Issuer in tokens matches your public API origin (http://localhost:3001 in this environment). Set OIDC_ISSUER on the API to the same value in production.
What you need from the dashboard
- client_id — public identifier for your frontend.
- Redirect URI(s) — must match character-for-character (including trailing slashes).
- Scopes — typically
openid email. Always includeopenid. - No client secret for standard web login buttons (public client + PKCE).
Button preview
Continue with plus the official idizer-logo-mark.png used on idizer.com login. Prefer the Idizer embed script on your site (PKCE stays on your origin). OAuth inside an iframe is not supported.
Preview only — use embed snippet below on your site
<!-- 1) Login page -->
<script src="https://idizer.com/embed/idizer-sso.js" async></script>
<div
class="idizer-sso-signin"
data-client-id="YOUR_CLIENT_ID"
data-redirect-uri="https://yoursite.com/auth/idizer/callback"
data-api-origin="http://localhost:3001"
data-scope="openid email"
data-theme="light"
></div>
<!-- 2) Callback page (https://yoursite.com/auth/idizer/callback) -->
<p id="idizer-sso-status">Signing you in…</p>
<script src="https://idizer.com/embed/idizer-sso-callback.js"></script>
<script>
IdizerSsoCallback.handle({
sessionUrl: "/api/auth/idizer/session",
onSuccess: function () { window.location.replace("/"); },
onError: function (err) {
var status = document.getElementById("idizer-sso-status");
if (status) status.textContent = err.message;
},
});
</script>Script is served from Idizer and draws the official button on your page. Login opens in the top window with PKCE + nonce. Implement the callback on data-redirect-uri using the framework examples.
We do not recommend putting the OAuth redirect inside an iframe: your callback URL lives on your domain, so PKCE secrets must be stored there too. The embed script keeps branding on Idizer while running securely on your origin.
Copy into your web app
Copy into your project. Replace nothing if you opened this from your registered app — values are already filled in.
The browser module lives in src/lib. Mount the callback on the route that matches the redirect URI. The session route must run on your server, where the ID token is verified.
const IDIZER = {
issuer: "http://localhost:3001",
clientId: "YOUR_CLIENT_ID",
redirectUri: "https://yoursite.com/auth/idizer/callback",
scope: "openid email",
sessionUrl: "/api/auth/idizer/session",
};
const STORAGE_KEY = "idizer.oauth.v1";
const LOGIN_MAX_AGE_MS = 10 * 60 * 1000;
function bytesToBase64Url(bytes: Uint8Array) {
let binary = "";
for (const byte of bytes) binary += String.fromCharCode(byte);
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
}
function randomBase64Url(size: number = 32) {
const bytes = new Uint8Array(size);
crypto.getRandomValues(bytes);
return bytesToBase64Url(bytes);
}
async function sha256Base64Url(value: string) {
const digest = await crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode(value),
);
return bytesToBase64Url(new Uint8Array(digest));
}
function secretsMatch(left: string, right: string): boolean {
if (left.length !== right.length) return false;
let diff = 0;
for (let i = 0; i < left.length; i += 1) {
diff |= left.charCodeAt(i) ^ right.charCodeAt(i);
}
return diff === 0;
}
function readAuthorizationCallback(href: string): { code: string; state: string } {
const url = new URL(href);
const error = url.searchParams.get("error");
if (error) {
throw new Error(url.searchParams.get("error_description") || error);
}
const code = url.searchParams.get("code");
const state = url.searchParams.get("state");
if (!code || !state) {
throw new Error("Idizer did not return a login code.");
}
return { code, state };
}
function takeStoredLogin(): { verifier: string; state: string; nonce: string; createdAt: number } {
const raw = sessionStorage.getItem(STORAGE_KEY);
sessionStorage.removeItem(STORAGE_KEY);
if (!raw) throw new Error("This login did not start in this browser tab.");
const stored = JSON.parse(raw);
if (
typeof stored?.verifier !== "string" ||
typeof stored?.state !== "string" ||
typeof stored?.nonce !== "string" ||
typeof stored?.createdAt !== "number" ||
Date.now() - stored.createdAt > LOGIN_MAX_AGE_MS
) {
throw new Error("Login expired. Start again.");
}
return stored;
}
export async function startIdizerLogin() {
const verifier = randomBase64Url();
const challenge = await sha256Base64Url(verifier);
const state = randomBase64Url(16);
const nonce = randomBase64Url(16);
sessionStorage.setItem(
STORAGE_KEY,
JSON.stringify({ verifier, state, nonce, createdAt: Date.now() }),
);
const authorize = new URL("/oauth/authorize", IDIZER.issuer);
authorize.searchParams.set("response_type", "code");
authorize.searchParams.set("client_id", IDIZER.clientId);
authorize.searchParams.set("redirect_uri", IDIZER.redirectUri);
authorize.searchParams.set("scope", IDIZER.scope);
authorize.searchParams.set("state", state);
authorize.searchParams.set("nonce", nonce);
authorize.searchParams.set("code_challenge", challenge);
authorize.searchParams.set("code_challenge_method", "S256");
window.location.assign(authorize);
}
/** Check state, then hand the one-time proof to your server. The server exchanges it. */
export async function finishIdizerLogin(href: string = window.location.href) {
const callback = readAuthorizationCallback(href);
const stored = takeStoredLogin();
window.history.replaceState({}, "", window.location.pathname);
if (!secretsMatch(callback.state, stored.state)) {
throw new Error("Login state did not match. Start again.");
}
const response = await fetch(IDIZER.sessionUrl, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
code: callback.code,
codeVerifier: stored.verifier,
nonce: stored.nonce,
}),
});
if (!response.ok) {
throw new Error("Your server rejected the Idizer login.");
}
}import { useEffect, useState } from "react";
import { finishIdizerLogin } from "@/lib/idizer-auth";
export function IdizerCallbackPage() {
const [error, setError] = useState<string | null>(null);
useEffect(() => {
let cancelled = false;
finishIdizerLogin()
.then(() => {
if (!cancelled) window.location.replace("/");
})
.catch((cause: unknown) => {
if (!cancelled) {
setError(cause instanceof Error ? cause.message : "Login failed");
}
});
return () => {
cancelled = true;
};
}, []);
if (error) return <p role="alert">{error}</p>;
return <p>Signing you in…</p>;
}
// Login screen:
// import { startIdizerLogin } from "@/lib/idizer-auth";
// <button type="button" onClick={() => void startIdizerLogin()}>Continue with Idizer</button>import { createRemoteJWKSet, jwtVerify } from "jose";
const ISSUER = "http://localhost:3001";
const CLIENT_ID = "YOUR_CLIENT_ID";
const REDIRECT_URI = "https://yoursite.com/auth/idizer/callback";
const jwks = createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`));
export type IdizerProfile = {
subject: string;
email: string | null;
};
export async function completeIdizerLogin(input: {
code: string;
codeVerifier: string;
nonce: string;
}): Promise<IdizerProfile> {
if (!input.code || !input.codeVerifier || !input.nonce) {
throw new Error("Missing login proof");
}
const tokenResponse = await fetch(`${ISSUER}/oauth/token`, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
body: new URLSearchParams({
grant_type: "authorization_code",
code: input.code,
redirect_uri: REDIRECT_URI,
client_id: CLIENT_ID,
code_verifier: input.codeVerifier,
}),
});
if (!tokenResponse.ok) {
throw new Error("Idizer refused the authorization code");
}
const tokens = (await tokenResponse.json()) as { id_token?: string };
if (!tokens.id_token) throw new Error("Idizer did not return an ID token");
const { payload } = await jwtVerify(tokens.id_token, jwks, {
issuer: ISSUER,
audience: CLIENT_ID,
algorithms: ["RS256"],
clockTolerance: 60,
maxTokenAge: "10m",
});
if (payload.nonce !== input.nonce) {
throw new Error("ID token nonce does not match this login");
}
if (payload.email_verified === false) {
throw new Error("Idizer email is not verified");
}
return {
subject: String(payload.sub),
email: typeof payload.email === "string" ? payload.email : null,
};
}
/** Cookie flags for the session you issue. Never store id_token itself. */
export const COOKIE = {
httpOnly: true,
secure: true,
sameSite: "lax" as const,
path: "/",
maxAge: 60 * 60 * 24 * 14,
};
// Wire completeIdizerLogin to POST /api/auth/idizer/session.
// Set the cookie from createSession(profile), using the COOKIE flags above.
// Return 401 with { "error": "login_failed" } and do not describe which check failed.The browser checks state and sends the one-time code to your server. Your server exchanges it, verifies the ID token with JWKS, and sets an httpOnly session cookie. Do not store the ID token in localStorage.
Server session
This is the Next.js route. The other framework tabs include the same verification. Install jose on the server. createSession is your own session, not the Idizer token.
// lib/idizer-session.ts
import { createRemoteJWKSet, jwtVerify } from "jose";
const ISSUER = "http://localhost:3001";
const CLIENT_ID = "YOUR_CLIENT_ID";
const REDIRECT_URI = "https://yoursite.com/auth/idizer/callback";
const jwks = createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`));
export type IdizerProfile = {
subject: string;
email: string | null;
};
export async function completeIdizerLogin(input: {
code: string;
codeVerifier: string;
nonce: string;
}): Promise<IdizerProfile> {
if (!input.code || !input.codeVerifier || !input.nonce) {
throw new Error("Missing login proof");
}
const tokenResponse = await fetch(`${ISSUER}/oauth/token`, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Accept: "application/json",
},
body: new URLSearchParams({
grant_type: "authorization_code",
code: input.code,
redirect_uri: REDIRECT_URI,
client_id: CLIENT_ID,
code_verifier: input.codeVerifier,
}),
});
if (!tokenResponse.ok) {
throw new Error("Idizer refused the authorization code");
}
const tokens = (await tokenResponse.json()) as { id_token?: string };
if (!tokens.id_token) throw new Error("Idizer did not return an ID token");
const { payload } = await jwtVerify(tokens.id_token, jwks, {
issuer: ISSUER,
audience: CLIENT_ID,
algorithms: ["RS256"],
clockTolerance: 60,
maxTokenAge: "10m",
});
if (payload.nonce !== input.nonce) {
throw new Error("ID token nonce does not match this login");
}
if (payload.email_verified === false) {
throw new Error("Idizer email is not verified");
}
return {
subject: String(payload.sub),
email: typeof payload.email === "string" ? payload.email : null,
};
}
/** Cookie flags for the session you issue. Never store id_token itself. */
export const COOKIE = {
httpOnly: true,
secure: true,
sameSite: "lax" as const,
path: "/",
maxAge: 60 * 60 * 24 * 14,
};
// app/api/auth/idizer/session/route.ts
import { NextResponse } from "next/server";
import { createSession } from "@/lib/session";
import { completeIdizerLogin, COOKIE } from "@/lib/idizer-session";
export async function POST(request: Request) {
try {
const profile = await completeIdizerLogin(await request.json());
const response = NextResponse.json({ ok: true });
response.cookies.set("session", await createSession(profile), COOKIE);
return response;
} catch {
return NextResponse.json({ error: "login_failed" }, { status: 401 });
}
}Claims & email scope
sub is a stable pairwise identifier for your app. With the email scope, email and email_verified reflect the address the user selected at consent (Idizer mailbox or linked email).
Security checklist
- Use PKCE on every authorization request (S256 only).
- Compare
stateon callback, then delete the stored login before calling your server. - Remove
codefrom the address bar immediately. - Exchange the code on your server. Verify the ID token there:
iss,aud,nonce, RS256 via JWKS. - Set your own httpOnly session cookie. Do not store the ID token in the browser.
- Keep redirect URIs on HTTPS in production.
- Request minimum scopes; store only what you need.