Integration overview Developer
Last updated Aug 16, 2026
Integration overview
You can add sign-in to a website or app with Swaymoon Account. Swaymoon Account is an identity provider (IdP) that follows OAuth 2.1 and OpenID Connect. After the user signs in and authorizes on the official domain, your app exchanges an authorization code for tokens and reads user info.
This page is under Swaymoon Developer → Guides → Identifiers. Register and manage clients in the Developer portal. Read Registration and configuration in this directory first.
To view developer docs, turn on Developer Mode in the upper right of Docs.
Document index
Under Identifiers:
| Document | Contents |
|---|---|
| Registration and configuration | Create an identifier in the Developer portal; configure redirect URIs, optional privacy policy URL, scopes, and secrets (if any) |
| Authorization code and PKCE | Start browser authorization, exchange tokens, and refresh tokens |
| Tokens and user info | ID Token, Access Token, JWKS, UserInfo, and sub |
| Scopes and consent | scope, the consent page, and required vs optional scopes |
| Examples and troubleshooting | curl snippets, common error codes, and a checklist |
| Integrate a confidential client with generative AI | With a server, generate confidential-client integration code with AI |
| Integrate a public client with generative AI | For a frontend-only / static site, generate public-client integration code with AI |
| Minimal Python example | Public and confidential PKCE demos on one page; by default requests all profile scopes and shows the authorization confirmation page. JWT assertion token exchange is in Authorization code and PKCE and Examples and troubleshooting |
Environments and endpoints
| Purpose | Production |
|---|---|
| User sign-in / consent page | https://passport.swaymoon.com |
| Issuer (OIDC API) | https://api-passport.swaymoon.com |
| Developer portal | https://develop.swaymoon.com |
| Discovery document | https://api-passport.swaymoon.com/.well-known/openid-configuration |
For local testing, the Issuer is often http://127.0.0.1:10001; use your environment variables. Always treat URLs in the discovery document as authoritative so you do not hard-code paths that may change.
Common protocol endpoints (Issuer as prefix):
| Endpoint | Path |
|---|---|
| Authorize | /oauth2/authorize |
| Token | /oauth2/token |
| JWKS | /oauth2/jwks |
| UserInfo | /userinfo |
| Revoke | /oauth2/revoke |
| Introspect | /oauth2/introspect |
ID Token uses ES256 (elliptic curve) signing. The portal supports three client types, all with PKCE required (S256):
| Type | Token endpoint auth | Token exchange | Refresh Token |
|---|---|---|---|
| Confidential client | client_secret_basic | HTTP Basic + code_verifier | Yes (about 180 days) |
| Public client | none | Body client_id + code_verifier | No (re-authorize after expiry) |
| JWT assertion client | private_key_jwt | client_assertion + code_verifier | Yes (about 180 days) |
Recommended path
sequenceDiagram
participant App as Your app
participant Browser as User browser
participant Passport as Account
App->>Browser: 302 redirect to authorize (with PKCE)
Browser->>Passport: Sign in (if needed)
Browser->>Passport: Consent to scopes
Passport->>Browser: 302 redirect to redirect_uri?code=
Browser->>App: authorization code
App->>Passport: POST token (code + verifier; confidential also sends Basic; JWT also sends client_assertion)
Passport->>App: access_token + id_token (confidential and JWT also get refresh_token)
App->>Passport: GET UserInfo
Passport->>App: User claims
- In the Developer portal, register an identifier per Registration and configuration, choosing confidential, public, or JWT assertion. For a confidential client, store the one-time
client_secretsecurely. For JWT assertion, submit only a public key; keep the private key on your server. - Implement the authorization-code flow per Authorization code and PKCE (PKCE required).
- Validate
id_token(Issuer, audience, signature, and expiry) and call UserInfo with the Access Token. - Use the
subreturned by Swaymoon Account as your primary key for the user (pairwise; see Tokens and user info).
Design notes (read first)
- Authorization code + PKCE: portal apps cannot skip
code_challenge. - Confidential client: exchange the code with HTTP Basic (
client_id/client_secret) and also sendcode_verifier. - Public client: no
client_secret. Sendclient_idandcode_verifierin the form when exchanging the code. Do not put a “pretend secret” in the frontend. See Integrate a public client with generative AI and Minimal Python example. - JWT assertion client: no
client_secret. Sendclient_id,code_verifier, and aclient_assertionsigned with your private key (ES256). The portal stores only the public key; never upload the private key or put it in the frontend. Concept and trade-offs: Registration and configuration. Request format: Authorization code and PKCE. - Consent page: the user must explicitly confirm on the authorization page every sign-in (no silent skip).
openidis always required.emailand profile field scopes can be required, optional, or not requested. Required scopes need a reason and a privacy policy in the portal. When scopes change, the user sees added / removed contrast. Existing production clients do not need code changes for this; new clients should follow the latest Scopes and consent. - Pairwise
sub: the same person gets a different, stablesubunder each developer team. Do not use email as the unique primary key. - Email claim: when
emailis granted, UserInfo returns an address you can contact. The user may choose a regular email or Hide My Email (a relay; the real address is not given to you). Treat either as a normal email. Usesubas the account primary key.
Compliance and branding
- Sign-in and authorization must go to the official Swaymoon Account domain. Do not build a fake login page to collect passwords.
- Request only the minimum
scopeyour product needs. - Follow the Swaymoon Account and Developer portal Terms of Use and Anti-Abuse Policy. For developer integration questions, contact hello@swaymoon.com.
Next: after Registration and configuration, implement Authorization code and PKCE.