Skip to main content

Authentication & Tokens

SmarterElements embeds are authenticated with short-lived, narrowly-scoped, revocable STS tokens issued by your backend through the SmarterServices Security Token Service (STS). Your long-lived API credential never reaches the browser — your server exchanges it for a token that is scoped to a single element, a single end user, and a short lifetime, then hands that token to the SDK.
STS is a generic token service; SmarterElements embeds use the element token type. Each issued token is bounded by the permission ceiling of the credential that created it — a token can never grant more than its creator already has.
For general-purpose short-lived API access, STS also supports an api token type with a caller-supplied, ceiling-checked IAM policy. See STS Tokens for both minting methods and their shared security guardrails.

How it works

  1. The browser asks your backend for an embed (authenticated however you already authenticate your users).
  2. Your backend calls the STS endpoint using its own API credential and gets back a token set.
  3. Your backend returns the signed elementToken (and optionally the runtime stsToken) to the browser.
  4. The browser passes them to elements.create(...); the SDK silently refreshes before expiry.

Issue a token

Call this from your backend (never the browser — it requires your API credential):

Request body

The caller must hold the sp:CreateStsToken action; the resulting token’s policy is validated as a subset of the caller’s effective policy before anything is minted.

Response 201

Pass the token to the SDK

Give the SDK the signed elementToken as elementToken, the opaque runtime credential as stsToken, and an onTokenRefresh callback that fetches a fresh token set from your backend. The SDK schedules a silent refresh before expiry (default at 80% of the TTL) and stops at absoluteExpiresAt.
Never embed a long-lived API key or a broad spToken in the browser. Only the short-lived elementToken (and optionally the scoped runtime stsToken) should ever reach client-side code.

Silent refresh

Long-lived embeds outlive a single 15-minute token, so the SDK rotates them automatically:
  • The SDK schedules a refresh at ~80% of the current token’s TTL (floored at 5s to avoid hot loops).
  • Your onTokenRefresh callback calls the refresh endpoint and returns a new token set.
  • The new stsToken (runtime credential) is forwarded to the element and a tokenRefreshed event fires (refresh rotates the credential; the signed elementToken is issuance-only).
  • Once absoluteExpiresAt (8h from the first token) is reached, refresh stops and tokenExpired fires.
The refresh cycle runs in this order:
The SDK owns the scheduling and lifecycle — you don’t track expiry or wire up timers. But you must supply the onTokenRefresh callback: the STS refresh endpoint requires your API credential, which must never live in the browser, so the callback bounces the refresh through your backend. If you omit it, the token simply expires and the embed ends when the TTL runs out.

Wire up the refresh callback

Pass onTokenRefresh to elements.create(...). The SDK calls it shortly before expiry; it must fetch a fresh token set from your backend (which calls the STS refresh endpoint with your API credential) and return it:

onTokenRefresh return shape

The callback must resolve with an StsTokenSet containing: Resolving with a valid set applies the new tokens and fires tokenRefreshed. Throwing or returning a rejected promise fires tokenExpired and ends the session.

Refresh endpoint

Returns a new token set with a previousSid field. The old credential is revoked once the replacement is minted. Refresh requires the sp:RefreshStsToken action and reuses the original token’s scoped policy — a refresh can never widen permissions or extend past the absolute session lifetime.

Security model


For end users

When you open a SmarterElements embed (for example, a proctoring session viewer inside your LMS), the embed signs in automatically using a temporary, single-purpose access pass created just for you by your institution’s system. This pass only works for that one embed, expires after a short time, and renews quietly in the background while you keep working — so you never have to log in again inside the embed, and your full account credentials are never shared with it. If you leave the embed open for a long time, it will eventually end the session for security and you can simply reopen it.