Gao ID token verification
Gao ID is the identity your users already have. Your backend trusts a Gao ID token by verifying it against the issuer’s public keys — no call to Gao is needed. Configure two values for this network, plus the audience Gao assigns to your app:
| Setting | Value on the Product network |
|---|---|
Issuer (GAO_ID_ISSUER) |
https://id.gao.global |
Key set (GAO_ID_JWKS_URL) |
https://id.gao.global/.well-known/jwks.json |
Audience (GAO_ID_AUDIENCE) |
assigned to your app by Gao |
Signing users in from your own app’s front end needs Gao to register the app first (its audience and its allowed origin); there is no self-service registration yet, and Gao provides the sign-in details with the registration.
Verify a token in your backend
Section titled “Verify a token in your backend”A JWT that is ES256-signed by one of the issuer’s keys, with iss equal to the issuer, aud equal to your audience,
a live exp and a non-empty sub, is an authenticated Gao user.
- Read
Authorization: Bearer …(401 if missing). - Split
header.payload.signature; rejectalgother thanES256andtypother thanJWT. - Look up
kidin the key set (cache it up to 5 minutes; refresh once on a miss). - Verify the ES256 signature over
header.payload. - Check
iss,aud, a non-emptysub,exp > now, andnbf ≤ now + 30when present. - Use
sub(the Gao ID root id) as your user id.
A dependency-free key loader (Node 20+, Deno, Cloudflare Workers), given the key-set URL above:
const CACHE = { keys: null as Map<string, CryptoKey> | null, fetched: 0 };async function loadKey(jwksUrl: string, kid: string): Promise<CryptoKey | null> { if (!CACHE.keys || Date.now() - CACHE.fetched > 5 * 60 * 1000) { const r = await fetch(jwksUrl); if (!r.ok) throw new Error(`jwks_http_${r.status}`); const { keys } = (await r.json()) as { keys: { kty: string; crv: string; x: string; y: string; kid: string }[] }; const out = new Map<string, CryptoKey>(); for (const k of keys) { if (k.kty !== 'EC' || k.crv !== 'P-256') continue; out.set(k.kid, await crypto.subtle.importKey('jwk', { kty: 'EC', crv: 'P-256', x: k.x, y: k.y, ext: true }, { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify'])); } CACHE.keys = out; CACHE.fetched = Date.now(); } return CACHE.keys.get(kid) ?? null;}