SSO uses the OAuth 2.0 authorization code flow. Your app sends the user to your
program’s authorization URL, gets a short-lived code back on your redirect URI, and
exchanges that code for tokens at your program’s token URL.
Both URLs and your client id come from Orenda and are
different for every program.
Only the authorization code flow is enabled. The implicit and password grants are not
available on any program.
1. Send the user to sign in
Open it in a system browser or a secure webview — not an embedded view that your app can
read, and not an iframe.
state — a random value you generate and check on the way back. It protects against
cross-site request forgery. Always send it.
code_challenge — PKCE. Required for public clients (mobile, single-page apps),
which are issued without a client secret. Generate a random code_verifier, send its
SHA-256 hash base64url-encoded as the challenge, and keep the verifier for step 2.
redirect_uri — must match the one registered for your program exactly,
including scheme, host, port, and path.
Skipping the provider chooser
By default the user sees a screen offering the available sign-in options. If your program
has one identity provider and you want to go straight to it, add its name:
Orenda gives you this name with the rest of your program values.
2. Handle the redirect
The user signs in with your identity provider and lands back on your redirect URI:
Check state matches before you do anything else. If it doesn’t, drop the response.
On failure you get ?error=…&error_description=… instead — show the user a retry, and do
not treat it as a server outage.
3. Exchange the code for tokens
A confidential client sends its secret instead of code_verifier, as HTTP Basic auth
(Authorization: Basic base64(client_id:client_secret)).
The code is single-use and expires within minutes. Exchange it immediately on receipt.
A replayed code fails, and a code left sitting in a URL bar or a log is a credential.
4. Call the API
Exactly as any other program — the ID token is the bearer token:
Use the id_token, not the access_token. The gateway checks the token’s token_use
claim and rejects an access token with 403 before it reaches the endpoint. This catches
people out on SSO because the token response lists access_token first.The access_token is only used as a request body field, for TOTP step-up
confirmations and Log out.
Lifetimes and refreshing
To refresh, post to the same token URL:
SSO sessions do not use POST /v1/auth/refresh. That endpoint
is for sessions created by the Orenda sign-in endpoints. An SSO refresh token presented
there will not work — refresh at your program’s token URL instead.
The refresh response does not include a new refresh_token. Keep the one you were
issued at step 3 and reuse it until it expires. Storing the response wholesale and
overwriting your saved refresh token with undefined is the single most common SSO bug —
it logs the user out after five minutes.
A worked refresh
Signing out
Send the user to your program’s logout URL to end the session at the identity layer,
and clear the tokens you hold. Clearing tokens alone is not a sign-out: the next
authorization request would sign the user straight back in from their provider session.
Common problems