OAuth & Widget Viewer Identity
Expose your own server's API inside a hub page (API widgets) and know WHO is looking, without asking viewers to paste headers, and without receiving personal data you did not ask for. Two layers, both standard:
Identity is authentication, not authorization. A verified token proves exactly two things: the request came from a signed-in Yroun account, and this is that account's stable pseudonym for this hub. It does NOT imply hub membership, hub visibility, a plan, or any entitlement. Any signed-in Yroun account can obtain a token for any hub uid, including one they are not a member of. So AUTHORIZATION is always yours: decide access from the viewerId you have on file (your own allowlist, role table, or the Layer 2 email link), and always compare the hubUid the verify response returns against your own hub before trusting the viewerId.
Choosing your integration path: token verify vs proxy headers
Layer 1 identity reaches your server by one of two paths, and BOTH deliver the SAME per-hub pairwise viewerId. Start with either and switch later without losing continuity. They differ in trust model and integration cost:
Rule of thumb: if identity gates anything security-sensitive (paid content, per-viewer permissions, rate limits), verify the token. Proof beats assertion. For personalization or analytics, or when your API key must stay server-side, the Connection proxy headers are the zero-work answer.
Layer 1: Verify the widget token
In the widget's auth tab pick Yroun ID. Every signed-in viewer's request to your server then carries this header automatically (5-minute tokens, refreshed by the widget, nothing to configure per user):
Authorization: YrounWidget <token>
Your server verifies the token with your own API key (each verification is metered against your credits, and the viewer never pays for your identification):
curl -X POST https://api.yroun.com/oapi/widget-tokens/verify \
-H "X-API-Key: yroun_key_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "token": "<value after the YrounWidget prefix>" }'{ "valid": true, "viewerId": "3f9c…32-hex, stable per (viewer, hub)", "hubUid": "…" }Membership disclosure: one-line authorization for your own hub
By default a valid token proves authentication only. When the dashboard you are protecting belongs to YOUR OWN hub, ask verify to also disclose membership. Add includeMembership: true and your admin policy becomes one line: a JOINED ADMIN passes.
curl -X POST https://api.yroun.com/oapi/widget-tokens/verify \
-H "X-API-Key: yroun_key_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "token": "<token>", "includeMembership": true }'{ "valid": true, "viewerId": "…", "hubUid": "…", "membership": { "isMember": true, "authority": "ADMIN" } }Pre-provisioning: read your members' viewerIds
To whitelist specific members BEFORE they ever open your dashboard, or to see which member a stored viewerId belongs to, the members list can include each member's own-hub viewerId. Owner/admin surface, members only:
curl "https://api.yroun.com/oapi/hubs/{hubUid}/members?includeViewerId=true" \
-H "X-API-Key: yroun_key_xxxxxxxxxxxx"Pattern: an application & approval dashboard
The shape that runs real multi-admin operations on a single hub page, end to end:
Layer 2: Sign in with Yroun (email confirmation)
Standard OAuth 2.0 Authorization Code + PKCE (S256, required, no client secret in the current version; keep the code_verifier in your server-side session). The consent screen shows exactly one permission: "Confirm your email and name" (scope: identity). An identity-scope token can call userinfo and nothing else.
# 2) token exchange curl -X POST https://oauth.yroun.com/oauth/token \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=authorization_code&code=CODE&redirect_uri=URI&client_id=ID&code_verifier=VERIFIER" # 3) identity curl https://oauth.yroun.com/oauth/userinfo \ -H "Authorization: Bearer ACCESS_TOKEN"
Server samples: Spring / Node
No Yroun SDK is required. Both layers are one standard HTTP call each. Copy-paste starting points:
// Spring: verify a widget token (Layer 1)
record VerifyResponse(boolean valid, String viewerId, String hubUid) {}
public Optional<VerifyResponse> verify(String authorization) {
if (authorization == null || !authorization.startsWith("YrounWidget "))
return Optional.empty();
VerifyResponse res = restClient.post()
.uri("https://api.yroun.com/oapi/widget-tokens/verify")
.header("X-API-Key", apiKey)
.body(Map.of("token", authorization.substring(12)))
.retrieve().body(VerifyResponse.class);
return (res != null && res.valid()) ? Optional.of(res) : Optional.empty();
}// Node / Next.js: start the OAuth link (Layer 2)
const verifier = crypto.randomBytes(48).toString('base64url')
const challenge = crypto.createHash('sha256').update(verifier).digest('base64url')
// keep verifier + state in the server session, then redirect to:
// https://oauth.yroun.com/oauth/authorize?response_type=code&client_id=...
// &redirect_uri=...&scope=identity&state=...&code_challenge=<challenge>
// &code_challenge_method=S256
// callback: state check -> token exchange -> userinfo
const tokens = await (await fetch('https://oauth.yroun.com/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ grant_type: 'authorization_code', code,
redirect_uri: REDIRECT_URI, client_id: CLIENT_ID, code_verifier: verifier }),
})).json()
const userinfo = await (await fetch('https://oauth.yroun.com/oauth/userinfo', {
headers: { Authorization: `Bearer ${tokens.access_token}` },
})).json() // { sub, email, name, locale }Spring Security users can register Yroun as a standard OAuth2 client provider (authorization-uri / token-uri / user-info-uri from the well-known metadata) instead of hand-rolling the callback.
Token rules you must honor
Register your app (get a client_id)
Self-serve, no review, no waiting on us: console.yroun.com → Your Apps. Two fields are required and the client_id is issued immediately.
Then choose where the app runs, because that decides whether a secret exists at all. A browser, mobile or extension client is PUBLIC: no secret is issued and it authenticates with PKCE. A server-side app is CONFIDENTIAL and receives a client secret shown exactly once. We keep only its hash, so a lost secret is rotated, never looked up.
Everything else is optional and editable later: description, logo URL, privacy policy and terms links. A privacy policy is NOT required to register; when you provide one it is linked on the consent screen, and after the grant the user's email and name are governed by your policy. Scopes default to identity. Request only what you need, since every one you tick becomes a line the user reads before approving.
The widget-verify API key is separate and also self-service: your hub → Settings → API Keys.
Or register with your API key, no browser
Everything the console page does is also an Open API capability your own key holds, so registration and rotation can be automated and never require a logged-in session. Same rules, same caps, same owner: the app belongs to the key owner, and you cannot register on behalf of anyone else.
curl -X POST "https://oapi.yroun.com/oauth-apps" \
-H "X-API-Key: $YROUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"My App","redirectUris":["https://example.com/callback"],"scopes":["identity"],"confidential":true}'
# -> { clientId, clientSecret, clientType, redirectUris, scopes, ... }
# clientSecret appears in THIS response only.Checklist
Stuck, or something here is wrong? Send us a message