On this page
You finish with an application of your own that registers as an OIDC client of the MSO issuer, signs a user in, reads the organization and brand the user launched from, calls one Platform API endpoint with the right scope, and verifies a signed webhook. Plan for about 90 minutes, longer if the platform operator has to add your client entry.
Before you start#
- A running MSO Cloud stack with the issuer enabled, and its issuer URL (
IDP_ISSUER, the platform origin, for examplehttps://msocloud.example). Bring-up is operator work:docs/runbooks/idp-issuer-bringup.md. Local development does not start the issuer. - A test organization that has your app enabled in the admin catalog, and a user who is a member of it.
- Node 26, and in your app
jose,openid-client(v6 API) and the platform contract package (sourcepackages/platform-contract, version 0.5.0, published to the GitHub package registry; pin an exact minor). Snippets import it asplatform-contract: use thenamefield of itspackage.json. The conformance testapps/idp/src/__tests__/conformance.test.tsruns the same flow and is the reference for every call below. - Background: Connect a satellite app, Platform API and events.
Steps#
Generate a signing key. The app authenticates with
private_key_jwt, ES256 only. Publish the public JWK, keep the private key in your own secret store, never in a repository.import { exportJWK, generateKeyPair } from 'jose'; const { privateKey, publicKey } = await generateKeyPair('ES256', { extractable: true }); const publicJwk = { ...(await exportJWK(publicKey)), kid: 'my-app-key-1', use: 'sig', alg: 'ES256', }; const privateJwk = { ...(await exportJWK(privateKey)), kid: 'my-app-key-1', alg: 'ES256' };Give the operator your client entry. The issuer reads a JSON array from
IDP_CLIENTS_JSONorIDP_CLIENTS_FILE, validated bystaticClientSchemainapps/idp/src/clients.ts. Redirect URIs are exact https literals (loopbackhttpis allowed), at most 8, no wildcard, no fragment.jwksholds 1 to 4 public EC P-256 keys and rejects anydmember.scopelists the OIDC scopes plus the platform scopes your app may request.[{ "client_id": "my-app", "client_name": "My app", "redirect_uris": ["https://my-app.example/auth/callback"], "post_logout_redirect_uris": ["https://my-app.example/"], "backchannel_logout_uri": "https://my-app.example/auth/backchannel-logout", "jwks": { "keys": [ <publicJwk> ] }, "grant_types": ["authorization_code", "refresh_token", "client_credentials"], "scope": "openid offline_access email profile platform:orgs.read platform:entitlements.read platform:events.write" }]The platform scope vocabulary is
PLATFORM_SCOPESinpackages/platform-contract/src/scopes.ts:platform:orgs.read,platform:entitlements.read,platform:social.read,platform:events.write. Marketplace and marketing data have no scope and no endpoint. For the launcher tile, a maintainer adds a satellite manifest with the sameclientId,launchUrlandscopesinpackages/plugin-host/src/registry.ts. Nothing checks that manifest and client entry agree; a mismatch surfaces as a refused token.Sign a user in. Authorization code flow with PKCE (required for every client) and
private_key_jwt. Ask for the organization with the RFC 8707resourceparameter,https://msocloud.net/api/platform/orgs/<org_id>. That string isPLATFORM_AUDIENCEplus/orgs/and is not your issuer URL.import * as oc from 'openid-client'; import { importJWK } from 'jose'; const issuer = new URL(process.env.MSO_ISSUER_URL!); const key = await importJWK(JSON.parse(process.env.MSO_CLIENT_PRIVATE_JWK!), 'ES256'); const config = await oc.discovery( issuer, 'my-app', undefined, oc.PrivateKeyJwt({ key, kid: 'my-app-key-1' }), ); // 1. redirect the browser here; keep verifier, state and nonce in the user's session const verifier = oc.randomPKCECodeVerifier(); const state = oc.randomState(); const nonce = oc.randomNonce(); const authUrl = oc.buildAuthorizationUrl(config, { redirect_uri: 'https://my-app.example/auth/callback', scope: 'openid offline_access email profile', resource: `https://msocloud.net/api/platform/orgs/${orgId}`, code_challenge: await oc.calculatePKCECodeChallenge(verifier), code_challenge_method: 'S256', state, nonce, }); // 2. in the callback route const tokens = await oc.authorizationCodeGrant(config, new URL(callbackUrl), { pkceCodeVerifier: verifier, expectedState: state, expectedNonce: nonce, idTokenExpected: true, });Parse the verified ID-token claims with the contract schema instead of trusting them:
idTokenClaimsSchema.parse(tokens.claims()). The MSO claims are namespaced underhttps://msocloud.net/claims/(orgs,active_org,active_brand,super_admin); read them throughID_TOKEN_CLAIM_KEYS. The token carries at most 50 organizations; past thatorgs_truncatedis true and you callGET /me.Read the launch hint. When a user opens your tile, MSO Cloud redirects to your
launchUrlwithmso_org(always) andmso_brand(when a brand is active) as query parameters (apps/web/src/app/api/apps/launch/[app]/route.ts). They are navigation hints for an app that already holds a session and skips sign-in: the app may ignore them and must check access itself, here against theorgsclaim.const url = new URL(request.url); const hintOrg = url.searchParams.get('mso_org'); const hintBrand = url.searchParams.get('mso_brand'); const claims = idTokenClaimsSchema.parse(tokens.claims()); const member = claims[ID_TOKEN_CLAIM_KEYS.orgs].find((o) => o.id === hintOrg); if (!member) throw new Error('user is not a member of the launched organization'); if (hintBrand && member.brand_ids !== null && !member.brand_ids.includes(hintBrand)) { throw new Error('brand not granted'); // brand_ids: null means every brand }Call a Platform API endpoint. Every route needs one scope and a path organization equal to the token organization. A token is one organization, 600 seconds at most. For an org-level job use client credentials;
GET /meand/me/launcherneed a user-delegated token instead. This example reads entitlements (platform:entitlements.read).import { entitlementsResponseSchema } from 'platform-contract'; const res = await oc.clientCredentialsGrant(config, { scope: 'platform:entitlements.read', resource: `https://msocloud.net/api/platform/orgs/${orgId}`, }); const r = await fetch( `${process.env.MSO_PLATFORM_ORIGIN}/api/platform/v1/orgs/${orgId}/entitlements`, { headers: { Authorization: `Bearer ${res.access_token}` }, }, ); if (!r.ok) throw new Error(`platform api ${r.status} ${JSON.stringify(await r.json())}`); const { entitlements } = entitlementsResponseSchema.parse(await r.json());The same call in curl, with
$TOKENfrom the grant:curl -fsS -H "Authorization: Bearer $TOKEN" \ "$MSO_PLATFORM_ORIGIN/api/platform/v1/orgs/$ORG_ID/entitlements"The body matches
entitlementsResponseSchema:org_idandentitlements[]ofapp_id,plan,limits,valid_to,status(active,trial,suspended,expired). Errors are{error, error_description?}: 401invalid_token, 403insufficient_scopeororg_mismatch. IfPLATFORM_ISSUERorPLATFORM_JWKS_URLis unset on the platform, every route answers 404. To push an event,POST /api/platform/v1/eventswith scopeplatform:events.writeand acontent.publishedenvelope (contentPublishedEventSchema; body at most 64 KiB; a repeatedidanswers202withduplicate: true).Receive and verify a webhook. MSO Cloud POSTs one envelope (
id,type,org_id,occurred_at,data) withX-MSO-Signature: sha256=<hex>(HMAC-SHA256 over the raw body) andX-MSO-Event-Id. Verify before parsing, deduplicate on the event id, return 2xx quickly.import { platformEventSchema, verifyWebhookSignature, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_EVENT_ID_HEADER, } from 'platform-contract'; export async function POST(req: Request): Promise<Response> { const raw = await req.text(); // the exact bytes; never re-serialize if ( !verifyWebhookSignature( raw, req.headers.get(WEBHOOK_SIGNATURE_HEADER), process.env.MSO_WEBHOOK_SECRET!, ) ) { return new Response(null, { status: 401 }); } const event = platformEventSchema.parse(JSON.parse(raw)); if (await alreadySeen(req.headers.get(WEBHOOK_EVENT_ID_HEADER) ?? event.id)) { return new Response(null, { status: 200 }); } await handle(event); // org.app.changed, membership.changed, user.disabled, trends.updated return new Response(null, { status: 200 }); }Test the receiver without MSO Cloud by signing a body yourself. The
openssloutput equalssignWebhookBody:BODY='{"id":"evt-1","type":"user.disabled","org_id":"'$ORG_ID'","occurred_at":"2026-11-28T10:00:00Z","data":{"user_id":"u-1"}}' SIG="sha256=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$MSO_WEBHOOK_SECRET" -hex | sed 's/^.* //')" curl -i -X POST https://my-app.example/webhooks/mso \ -H "Content-Type: application/json" -H "X-MSO-Signature: $SIG" -H "X-MSO-Event-Id: evt-1" --data-raw "$BODY"Delivery is at-least-once and can arrive out of order: 408, 425, 429 and 5xx retry at 30 s x 2^(n-1) up to 6 h and 10 attempts, any other status is dead-lettered.
What does not exist#
- No webhook subscription write path. No screen or API creates
platform_webhook_subscriptionsrows (packages/schema/src/tables/platform-outbox.ts; one row per organization and app:url, encrypted secret,eventTypes). Until a path exists, MSO Cloud sends your app nothing, and wiring a receiver needs a reviewed schema and row-level-security change by the platform team. Supported alternative: reconcile by pollingGET /orgs/{id}/membersand/entitlements(cursor pagination,limitup to 200), and rely on the ID-token claims at each sign-in, because provisioning is token-first. Step 6 is still how you build and test the receiver. - No self-service client registration. Dynamic registration is off; a client change is an operator edit plus an issuer restart.
content.publishedhas no consumer inapps/orpackages/; it is stored for lineage only.- Logout: disabling a user in MSO Cloud sends an OIDC back-channel
logout_tokentobackchannel_logout_uri. Your endpoint revokes the local session bysid(logoutTokenClaimsSchema).
If it fails#
| Symptom | Cause |
|---|---|
invalid_ at the token endpoint |
The app is not installed, enabled and entitled for that organization, or the user is not a member, or resource is not https:/. |
invalid_ |
The key is not in jwks, kid differs, or the algorithm is not ES256. |
| Redirect refused | redirect_ is not an exact literal in the client entry. |
403 insufficient_ |
The grant did not include the route's scope, or the client entry's scope omits it. |
403 org_ |
The path organization differs from the token's org_. |