SSO is 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 aren’t 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 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 get no client secret. Generate a random code_verifier, send its SHA-256 hash base64url-encoded as the challenge, and keep the verifier for step 3.
  • 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 listing the available sign-in options. If your program has one identity provider and you want to skip that screen, 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. It isn’t 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 the moment you receive it. A replayed code fails, and a code sitting in a URL bar or a log is a credential.

4. Call the API

Same as any other program. The access token is the bearer token:

Lifetimes and refreshing

To refresh, post to the same token URL:
SSO sessions don’t use Refresh tokens. That endpoint is for sessions created by the Orenda sign-in endpoints. An SSO refresh token sent there fails. Refresh at your program’s token URL instead.
The refresh response doesn’t include a new refresh_token. Keep the one from step 3 and reuse it until it expires. Storing the response wholesale and overwriting your saved refresh token with undefined is the most common SSO bug. It logs the user out after five minutes.

Refresh example

Signing out

Clear the tokens you hold, then send the user to your program’s logout URL to end the session at the identity layer. Clearing tokens alone isn’t a sign-out: the next authorization request signs the user straight back in from their provider session.
logout_uri is where the user lands afterwards. It has to be one of the sign-out URLs registered for your program, the same way redirect_uri has to be registered for sign-in.
Use logout_uri, not redirect_uri. If you send redirect_uri (with response_type=code) to the logout URL, the session is ended and the user is then shown a hosted login page instead of being sent back to your app.

Common problems