Skip to main content
Early access: Company Sign-In is not live in production yet. Fluid enables it per company. Until it is enabled for your company, discovery and app registration return 404. Contact your Fluid representative or Fluid support to request early access.
This guide walks you through registering a Company Sign-In app, configuring a stock OpenID Connect library (openid-client), running the Authorization Code flow with PKCE (S256), state, and nonce, reading /userinfo, and renewing sessions with prompt=none.

Before you start

  • Confirm that Fluid has enabled Company Sign-In for your company.
  • Have a signed-in company administrator with the developer.update permission ready to register the app.
  • Decide on your app’s callback URL (for example, https://portal.northwind.example/callback in production or http://localhost:3000/callback locally).
1

Register your app

A company administrator manages apps through the company-apps API on api.fluid.app using their signed-in admin Bearer token (Authorization: Bearer <token>):
  • POST .../company-apps registers an app (requires developer.update).
  • GET .../company-apps lists apps with cursor pagination via page[cursor] and meta.pagination.next_cursor (requires developer.view).
  • POST .../company-apps/{client_id}/revoke revokes an app (requires developer.update).
The company-apps API is in early access and not yet published in the API Reference; your Fluid contact provides the versioned path prefix on api.fluid.app when enabling early access for your company, and the full operations will appear in the API Reference on release. Machine credentials (company API tokens, partner tokens, public tokens, and droplet installation tokens) are refused with 403 — only a signed-in company admin can manage Company Sign-In apps.Send these fields when creating an app:Where <company-slug> comes from: Fluid creates your company’s issuer URL (https://identity.fluid.app/c/<company-slug>) when you register your first app. By default, <company-slug> is your company’s Fluid subdomain in lowercase. You can pass a custom issuer_slug on that first registration as a lowercase DNS label (1 to 63 characters: a-z, 0-9, and inner hyphens -). Once set, your company’s issuer slug never changes.Redirect URI rules:
  • Must use https://, except http://localhost:<port>/... or http://127.0.0.1:<port>/... with an explicit port for local development.
  • No wildcards (*), fragments (#), user info (user:pass@), backslashes, or whitespace.
  • Matched byte for byte at both /authorize and /token.
Example create payload:
The 201 response returns a company_app object with everything your app needs:
Store client_id and issuer in your app’s environment configuration. Public apps have no client secret.
2

Configure a stock OpenID Connect library

Install openid-client (v6 or later):
Configure discovery using your company’s issuer URL and your app’s client_id. Because discovery advertises ES256 signing, PKCE S256, and your company’s endpoints under /c/<company-slug>/, stock library defaults work with no algorithm overrides:
lib/oidc.ts
Other stock OpenID Connect libraries — such as oauth4webapi (Auth.js v5) and go-oidc — also work with standard discovery from https://identity.fluid.app/c/<company-slug>. Always rely on discovery rather than hard-coding endpoint URLs.
3

Start the sign-in flow with PKCE, state, and nonce

Generate a fresh PKCE code_verifier, S256 code_challenge, state, and nonce on your server before redirecting the browser. Both state and PKCE S256 are required; omitting state or sending plain returns HTTP 400.
lib/oidc.ts
Save flow ({ codeVerifier, state, nonce }) in a short-lived (for example, 10-minute), encrypted, HttpOnly, Secure cookie with SameSite=Lax, then redirect the browser to url.
Use SameSite=Lax, not SameSite=Strict, on your flow cookie. The browser returns to your callback route via a cross-site redirect from Fluid’s sign-in page, and browsers do not send Strict cookies on cross-site redirects.
4

Handle the callback and read userinfo

When Fluid redirects back to your redirect_uri:
  1. Read and clear the flow cookie. If it is missing or expired, show a timeout message and let the person sign in again.
  2. Check whether the query string carries an error parameter (such as login_required after a silent renewal or temporarily_unavailable).
  3. Build the callback URL from your configured redirectUri plus the incoming query string so the redirect_uri sent to /token matches the registered URI byte for byte.
  4. Exchange the code with authorizationCodeGrant, which authenticates the token endpoint over HTTPS and validates iss, aud, exp, state, and nonce. (Pass oidc.enableNonRepudiationChecks in discovery options if you also want openid-client to verify the ES256 signature against JWKS on back-channel token responses.)
  5. Call fetchUserInfo on your server to read the person’s live profile and Fluid membership claims.
lib/oidc.ts
Create your app’s own encrypted HttpOnly session cookie using the returned claims:
  • Key users by (issuer, subject). Never key users by email, because email addresses can change. Never link an existing local account by email unless email_verified is true.
  • Cap your session cookie lifetime to expiresIn (at most 10 minutes). Because early access has no refresh tokens or sign-out notifications yet, capping your app session to expiresIn keeps your app in sync with Fluid sign-outs.
  • Keep accessToken on your server. Never expose it to browser JavaScript, and never send it to the Fluid API.
5

Renew sessions silently with prompt=none

Access tokens and ID tokens expire after 10 minutes (expires_in: 600 by default). People do not have to sign in again every 10 minutes.When your app’s session cookie expires on a page navigation, redirect the browser to your authorization endpoint with prompt: "none":
  • If the person’s Fluid session is still active and valid for your company, Fluid redirects straight back to your callback with a fresh code and no sign-in screen.
  • If the person signed out of Fluid or lost membership at your company, Fluid redirects back with error=login_required. Clear any local state and treat the person as signed out.

Next steps

Read the Company Sign-In reference for the full list of endpoints, scopes, claims, email_verified rules, error codes, and sign-out behavior.