Skip to main content

Authentication (SSO)

The single sign-on entry point and the browser session endpoints. The recommended way to log members in.

SSO-aware entry point (/auth/sso/authorize) and the cookie-backed browser endpoints (/auth/sso/session, /auth/sso/sessions, /auth/sso/logout). After a member logs in once via Discord, every subsequent project login on the same browser skips the Discord screen. Recommended default for new integrations.

GET/api/auth/sso/authorize

Recommended default for new "Login with MicroClub" buttons. Same query contract as GET /auth/authorize. If the caller has a valid mcdi_sso cookie, the Discord OAuth bounce is skipped and the browser is redirected straight to the platform's redirect_uri with ?code=...&state=.... Otherwise this falls back to the existing /auth/authorize flow (Discord OAuth).

Use GET /auth/authorize instead when you need to force a fresh Discord consent.

Authentication: None, this endpoint is public.

Parameters

NameInTypeRequiredDescription
client_idquerystring (uuid)yesProject ID (UUID) identifying the client application
redirect_uriquerystringyesURI to redirect back to after authentication. Must be whitelisted for the project.
server_idquerystringyesDiscord server ID to verify membership against
statequerystringyesOpaque state value passed through to the redirect. Use for CSRF protection.

Responses

StatusDescriptionBody
200object
302Redirects either to Discord OAuth (no SSO yet) or back to the platform with a fresh callback code (SSO hit).

Open in Swagger (opens in a new tab)

Destroy the global SSO session (log out everywhere)

POST/api/auth/sso/logout

Reads the mcdi_sso httpOnly cookie, destroys the SSO session, cascades to every project session for the same member, and clears the cookie. Idempotent - succeeds even if the cookie is missing.

Authentication: None, this endpoint is public.

Responses

StatusDescriptionBody
204SSO session destroyed and cookie cleared.

Open in Swagger (opens in a new tab)

Get current SSO session status

GET/api/auth/sso/session

Reads the mcdi_sso httpOnly cookie set after Discord login and returns the authenticated member. Returns 401 with { authenticated: false } when the cookie is missing or expired.

Authentication: None, this endpoint is public.

Responses

StatusDescriptionBody
200SsoSessionStatusDto
401SsoSessionUnauthenticatedDto

Open in Swagger (opens in a new tab)

List active project sessions under the current SSO session

GET/api/auth/sso/sessions

Returns one entry per active (non-expired) project session for the member identified by the mcdi_sso cookie. Token material is never returned. Returns 401 when the SSO cookie is missing or expired.

Authentication: None, this endpoint is public.

Responses

StatusDescriptionBody
200SsoProjectSessionListDto
401Missing or expired SSO cookie.

Open in Swagger (opens in a new tab)

Schemas

SsoMemberDto schema

FieldTypeRequiredDescription
avatarstring or nullno
discordIdstringyesDiscord user ID (same as id in MCDI)
idstringyes
usernamestringyes

SsoProjectSessionDto schema

FieldTypeRequiredDescription
createdAtstring (date-time)yes
expiresAtstring (date-time)yes
lastUsedAtstring (date-time) or nullnoLast time this project session was used. Not currently tracked on sessions, so returns createdAt as a best-effort fallback.
projectIdstringyes
projectNamestringyes
serverIdstring or nullno

SsoProjectSessionListDto schema

FieldTypeRequiredDescription
sessionsarray of SsoProjectSessionDtoyes

SsoSessionStatusDto schema

FieldTypeRequiredDescription
authenticatedbooleanyes
expiresAtstring (date-time)yes
memberSsoMemberDtoyes

SsoSessionUnauthenticatedDto schema

FieldTypeRequiredDescription
authenticatedbooleanyes

Source: apps/api/openapi.json.