The first-party social-login plugin (plugins/social-login, providerType: social-login, plugin API 1.4) lets players sign up and sign in with an account they already have: Google, Discord, X, Apple (on the web and natively in the iOS app), and any OpenID Connect provider you add (Microsoft Entra ID, Keycloak, Auth0, Okta, GitLab, Authentik, your own). It is also the hub for login providers: its admin page lists the providers other plugins register, so every way to sign in is in one place.
The plugin only describes the providers. Core does the sign-in itself: the OAuth 2.0 / OpenID Connect round trip with PKCE, state and nonce, the id_token checks, the account rules (no silent merge by email, no provider sign-in for admins, two-factor authentication), the "Continue with …" buttons in every theme and the mobile app, and Settings → Sign-in methods for players.
It’s sold separately as social-login-<version>.tgz; Poker Engine releases don’t include it. Install it with Upload plugin on Extensions › Plugins, which shows the consent dialog (see Installing the First-Party Plugins). It asks for two capabilities:
| Capability | Why |
|---|---|
auth:provider | Register login providers. High trust: a provider decides who is signed in. |
storage | Keep the provider settings, and the client secrets encrypted (registry.secrets). |
For operators
Before you start: the Site URL
Providers send players back to a callback URL that core builds from the site URL (Settings › Server & Email Delivery, Site URLs › Base URL):
<Site URL>/api/v1/auth/external/<provider id>/callback
For example https://poker.example.com/api/v1/auth/external/google/callback. Set the Site URL to the public https address players use before you register the callback at a provider; if you change it later, update the callback at every provider. The admin page shows each provider’s exact callback URL with a copy button.
The admin page
Extensions › Plugin Pages › Social Login (/admin/plugins/social-login/page, also linked from Settings › Login Providers with Open Social Login). One card per provider:
| Part | What it does |
|---|---|
| Show … on the login pages | The enable switch. Every provider starts off. A provider shows a button and accepts sign-ins only while it is on and complete. |
| Status | Incomplete (a required value is missing; the card says which), Disabled (complete, registered, switched off) or Enabled. A provider core refused (for example because another plugin already uses the id) shows the reason. |
| Callback URL | What to enter at the provider as the redirect URI, with Copy. |
| Notes | Provider-specific setup notes and any other URL to register at the provider, with Copy (Apple’s notification endpoint). |
| Settings | The provider’s own fields (client ID, scopes, …). Save applies them at once. |
| Secrets | Write-only. A secret shows only Set or Not set. Type a value and press Set (or Replace); Clear removes it, which stops the provider. Secrets are stored encrypted and never sent back to the browser, not even to admins. |
| Trust verified email addresses | See Trust email. |
| New players | The sign-up mode, see New players. |
| Check settings | Lists what is missing or suspicious in the saved settings (for an OpenID Connect provider: an issuer that is not https, half a button colour scheme). It does not contact the provider. |
| Test sign-in | Runs the real sign-in against the provider, as you, and shows the profile it returned and how it was mapped (id, email, whether it is verified, name, avatar). Nothing is created or linked, so it works while the provider is switched off. Use it before you turn a provider on. |
Below the cards, Providers from other plugins lists the providers that other plugins register (for example Telegram), read-only, with a link to their plugin settings.
Players already linked, sign-up overrides and the mobile redirect allowlist are on Settings › Login Providers; linked accounts per player are under Players › Linked Accounts.
Who can change it. The same permissions as Settings › Login Providers: viewing the page needs settings:view (a1 and up) and every change needs settings:edit (super admin, a); group feature overrides apply. An admin who may only view sees the page read-only: the switches, fields, secrets, Check settings, Remove and Add are disabled, and a note says why. Test sign-in stays available (it changes nothing). An admin without settings:view does not see Social Login in the sidebar or the search; opening its address shows that the page needs the Settings › View permission, and nothing is loaded.
Setting up Google
- In the Google Cloud console, pick or create a project.
- OAuth consent screen (Google Auth Platform → Branding / Audience): give the app name, support email and your site’s links. While the app is in Testing, only the test users you list can sign in; publish it to let everyone in. The scopes the plugin asks for (
openid,email,profile) need no verification by Google. - Credentials → Create credentials → OAuth client ID, application type Web application. Under Authorised redirect URIs add the Google card’s callback URL. Authorised JavaScript origins are not needed.
- Copy the Client ID into the Google card and Save; set the Client secret.
- Optional: Google Workspace domain lets only accounts of one Workspace domain sign in (for a company or club). It is checked on the verified
hdclaim of the id_token, not only on the account chooser. - Test sign-in, then switch Google on.
Google asks players to choose an account every time (prompt=select_account), so a shared computer does not silently reuse the last account. The button follows Google’s branding guidelines (white, grey border, the four-colour "G").
Setting up Discord
- In the Discord Developer Portal, New Application.
- OAuth2 → Redirects: add the Discord card’s callback URL and save.
- Copy the Client ID (the application ID, a number) into the Discord card and Save. Reset Secret shows the client secret once: set it in the card.
- Test sign-in, then switch Discord on.
The default scopes are identify email: keep email, or new players have to type an email address. Consent screen chooses whether Discord asks a player who already authorised your app again (Only the first time, the default) or on every sign-in. Players without an avatar get Discord’s default avatar.
Setting up X
- In the X Developer Console, create a project and an app, and buy credits (see the note on access below).
- Open the app’s User authentication settings: turn on OAuth 2.0, choose the type of app (Web App, a confidential client with a client secret, unless you have a reason for a Native App, a public client), and add the X card’s callback URL under Callback URI / Redirect URL. X compares it by exact match, so copy it with the button.
- Under Keys and tokens, copy the OAuth 2.0 Client ID (not the API key) into the X card, choose the same Type of app and Save. For a Web App set the OAuth 2.0 Client Secret as well.
- Test sign-in, then switch X on.
X asks for users.read tweet.read, the scopes GET /2/users/me needs, and reads the player’s id, name, @username and profile picture. X is no OpenID Connect provider and gives no email by default: new players type one when they complete their profile, and it is verified like any address typed at registration. Turn on Request email to also ask for the users.email scope and the player’s confirmed_email; X returns it only when the account has a confirmed address. Trust verified email addresses is off for X by default; leave it off unless you are sure about it.
X API access. The X API is pay-per-usage: there is no subscription tier and no free plan in X’s pricing. You buy credits in the Developer Console and each request uses some. Every sign-in with X reads one user (GET /2/users/me, billed as User: Read), so sign-in stops working when the credits run out: set up auto-recharge. X allows 75 of these requests per player per 15 minutes (rate limits). The card repeats this note.
Setting up Apple
Sign in with Apple needs a paid Apple Developer Program membership and an app on the App Store that uses it: the website is grouped with that app. Everything below happens in Certificates, Identifiers & Profiles.
- The App ID. Under Identifiers, open the App ID of your iOS app (or register one) and enable Sign in with Apple as a primary App ID. While there, click Configure and enter the Apple card’s Server-to-server notification endpoint (see below), then save.
- The Services ID (web). Identifiers → + → Services IDs: give it a description and an identifier such as
com.example.poker.web; this is the client ID of the web sign-in and differs from the app’s bundle ID. Enable Sign in with Apple, Configure, choose your primary App ID, and under Website URLs enter your site’s domain and the Apple card’s callback URL as a return URL. Apple no longer asks for a domain verification file. Return URLs must be https with a domain name, neverlocalhostor an IP address, so Test sign-in needs your public site. - The key. Keys → +: enable Sign in with Apple, configure it with the primary App ID, and register. Download the
.p8file (Apple offers it once) and note the Key ID. Your Team ID is under Membership details. - In the Apple card enter the Services ID, Team ID and Key ID, Save, then paste the whole
.p8file (with its BEGIN and END lines) into Private key (.p8) and Set it. The plugin refuses anything but an Apple (P-256) key. It signs a short-lived client secret (an ES256 JWT, valid one hour) from it for each sign-in; you never renew anything by hand. - Optional: add the iOS app’s bundle ID(s) under iOS bundle IDs. The mobile app then uses the native Sign in with Apple sheet; the server accepts its identity token only for those bundle IDs.
- Test sign-in, then switch Apple on.
Apple sends the player’s name only the first time they sign in to your site, so the plugin stores it then. Later sign-ins carry only the stable Apple id and the email. Trust verified email addresses is on by default: Apple verifies the addresses it reports, including hidden ones.
Hidden email addresses. A player can choose Hide My Email: Apple then gives your site a …@privaterelay.appleid.com address that forwards to their real inbox. Apple delivers mail to these addresses only from email sources you register. Under Services → Sign in with Apple for Email Communication → Configure, add the domain (or the address) your site sends email from, and make sure it passes SPF (DKIM as well, if you can). Without that, these players get no verification, password reset or marketing mail. See Apple’s private email relay help.
Server-to-server notifications. The card shows the endpoint, <Site URL>/api/v1/plugins/social-login/apple/notifications. Register it on the primary App ID (step 1). Apple then tells your site when a player:
| Notification | What happens |
|---|---|
stops using Sign in with Apple with your app (consent-revoked) or deletes their Apple Account (account-deleted) | The Apple sign-in is unlinked and the player’s sessions end. The account stays: a player with a password or another sign-in method keeps using it; one without either recovers it with a password reset (if they had a real email) or through an admin. |
turns email forwarding off or on (email-disabled, email-enabled) | The Apple sign-in’s email is marked unverified or verified again. The account’s own email does not change. |
Every notification is signed by Apple and checked before anything happens. One that fails the check, has no jti, or is older than three days is refused; a repeated delivery (the same jti, remembered for three days plus twice the five-minute clock tolerance, the whole window a notification is accepted in) or one for a player who never signed in with Apple is acknowledged and changes nothing. A notification never changes an identity another plugin created.
App Store Guideline 4.8. An iOS app that offers a third-party or social login (Google, Discord, X, …) for the player’s account must also offer an equivalent login that limits data collection to name and email, lets players keep their email private and does not track them for advertising without consent (Guideline 4.8). Sign in with Apple meets that, which is why the mobile app shows it first on iOS (see Mobile app).
Adding an OpenID Connect provider
Any provider that publishes an OpenID Connect discovery document works. Press Add OpenID Connect provider:
| Field | |
|---|---|
| ID | 1 to 32 lower-case letters, digits and dashes. It becomes the provider id oidc:<ID> and part of the callback URL, and cannot be changed later. Once a provider is removed, its ID cannot be used again. |
| Button label | The provider’s name on the button: "Continue with <label>". |
| Issuer URL | The issuer exactly as the provider publishes it (the issuer value of its <issuer>/.well-known/openid-configuration). Core fetches the discovery document from there and checks that it names the same issuer. It cannot be changed after the provider is added (see below). |
| Client ID, Client secret | From the client (application) you register at the provider with the callback URL. The secret is not needed when Token endpoint authentication is None (a public client). |
| Scopes | Default openid email profile; openid is always sent. |
| Token endpoint authentication | HTTP Basic (the default, most providers), in the request body, or none. |
| Response mode | Query (the default) or form post. |
| Prompt | Optionally ask for the account chooser, a fresh sign-in or the consent screen every time. |
| Icon (SVG), Button background / text colour / border | Optional branding. Use the provider’s own sign-in button colours. Core removes scripts, links and event handlers from the SVG and limits it to 8 KB. |
The provider is registered as soon as the required fields are set, but stays off: press Add provider, copy the callback URL into the provider’s client, run Test sign-in, then switch it on. You can add up to 20 providers in total (Google and Discord count as one each).
Issuer examples (check your provider’s documentation for the exact value):
| Provider | Issuer |
|---|---|
| Microsoft Entra ID (one tenant) | https://login.microsoftonline.com/<tenant id>/v2.0 |
| Keycloak | https://<host>/realms/<realm> |
| Auth0 | https://<tenant>.<region>.auth0.com/ (with the trailing slash) |
| Okta | https://<org>.okta.com/oauth2/default |
| GitLab.com | https://gitlab.com |
Microsoft’s multi-tenant common and organizations endpoints publish a placeholder issuer, so they fail the issuer check; use a tenant-specific issuer.
The issuer is admin input, and core treats it that way: discovery, JWKS, token and userinfo requests must be https, may not reach private or loopback addresses, time out after 5 seconds and are capped at 256 KB (outside development and test environments). The plugin never fetches the issuer itself; Test sign-in is how you find out whether it works.
Remove … deletes the provider with its settings and secret and takes its button away at once. Players who signed in with it keep their accounts; those without a password recover them with a password reset (when their email is real) or through an admin.
Why the issuer and a removed ID are fixed. A player’s link to an OpenID Connect provider is stored as the provider id (oidc:<ID>) plus the sub the issuer gave them, and a sub only means something to the issuer that issued it. If the issuer of an existing provider could change, or a removed provider’s ID could come back with another issuer, the new issuer’s users would sign in to the accounts of whoever had that sub at the old one. Core prevents this: every identity records the issuer that signed it in (user_identities.issuer), and sign-in, link and re-authentication refuse an identity whose provider has another issuer now (IDENTITY_ISSUER_MISMATCH, 409); an admin can still unlink it under Users → Linked accounts. On top of that, so you do not end up with a provider whose old players cannot sign in, the page shows the issuer read-only once the provider exists (saving a different one is refused with SETTING_LOCKED), and an ID stays retired after its provider is removed (INSTANCE_RETIRED). To move to another issuer, add a new provider with a new ID, let players link it under Settings → Sign-in methods, then turn the old one off or remove it.
Trust email
A provider reports an email address and whether it verified it. With Trust verified email addresses on, core treats a verified address as proven: a new account gets it as a confirmed email without a verification mail, and an existing identity can sign in without a fresh email verification.
| Provider | Default |
|---|---|
| On (Google verifies the addresses it reports as verified) | |
| Discord | On (verified means Discord confirmed the address) |
| OpenID Connect | Off |
Turn it on for an OpenID Connect provider only if that provider verifies every address, for example your company’s directory. If anyone can register at the provider with any address, trusting it lets a player claim an email that is not theirs; the admin page asks you to confirm and keeps a warning on the card.
Trust never merges accounts: a provider email that matches an existing account always asks the player to sign in with that account’s password (and 2FA) first and then links the provider.
New players (sign-up mode)
| Mode | |
|---|---|
| Automatic (default) | Create the account at once when the provider gave everything needed (a usable username and a trusted verified email); otherwise show the short "complete your profile" step, pre-filled. |
| Always ask | Always show the complete-profile step first. |
| Link only | No new accounts. Only players who linked the provider in Settings → Sign-in methods can use it. |
Settings › Login Providers can override the mode per provider; the card shows when an override is in effect. Admin accounts never sign in through a provider, whatever the mode.
Test sign-in errors
| Message | Usual cause |
|---|---|
| The provider could not be reached or answered with an error | Wrong issuer, discovery document not found, issuer mismatch, wrong client ID or secret, the callback URL is not registered at the provider |
| The sign-in could not be verified or mapped | The id_token audience is another client, the provider’s clock is off, or the profile had no subject |
| The sign-in was cancelled at the provider | You pressed Cancel, or the provider refused (an app in testing mode, a user not allowed) |
| The sign-in expired or was started in another browser | More than 10 minutes passed, or the browser blocked the sign-in cookie; try again |
Several servers
Settings and secrets live in the database, so every node of a cluster sees them. The node that saves applies a change at once; the others pick it up within about 10 seconds (the enable switch) or on their next sign-in request (a new or removed provider).
For developers
Admin routes, on the admin router (admin session, CSRF on writes). Core adds a permission check to the admin routes of every plugin that declares auth:provider: settings:view for GET, settings:edit for POST, PUT, PATCH and DELETE (src/api/routes/admin/plugin-admin-permissions.ts). Without it the answer is 403.
| Route | |
|---|---|
GET /api/v1/admin/social-login/providers | Every module with its instances: settings, which secrets are set, what is missing, whether it is registered, the callback URL |
PUT /api/v1/admin/social-login/providers/:providerId | { common?: { enabled?, trustEmail?, signupMode? }, settings? } |
PUT /api/v1/admin/social-login/providers/:providerId/secrets/:key | { value } (write-only) |
DELETE /api/v1/admin/social-login/providers/:providerId/secrets/:key | Clear a secret |
POST /api/v1/admin/social-login/providers/:providerId/check | { ok, issues, testable, discoveryUrl }; no outbound request |
POST /api/v1/admin/social-login/modules/:module/instances | { instanceId, settings?, secrets?, common? } (multi-instance modules) |
DELETE /api/v1/admin/social-login/providers/:providerId | Remove an instance |
Storage: instance:<providerId> records in registry.storage and <providerId>:<secretKey> in registry.secrets.
Another provider can be its own plugin on the same public API (see Login Providers); it then appears read-only on this page.
Mobile app
The native app (packages/mobile) signs players in with the same providers as the web, from the server’s descriptors: login and register list every enabled provider that supports the mobile platform (GET /api/v1/auth/providers?platform=mobile), with the brand colours and icon the provider declares. Players link and unlink providers under Settings > Sign-in methods.
How a sign-in works
Browser providers (Google, Discord, X, Generic OIDC, and Apple on Android):
- The app makes a PKCE verifier (
expo-crypto) and keeps it in memory. It opens the system browser (WebBrowser.openAuthSessionAsync) on<API>/auth/external/<provider>/start?client=mobile&intent=login&appRedirectUri=poker://auth/callback&appCodeChallenge=<S256>. - The player signs in with the provider. The server redirects the browser to
poker://auth/callback?code=<ticket>(or?error=<CODE>). - The app posts
POST /auth/external/exchange { code, codeVerifier }withX-Auth-Client: mobile. The server checks the verifier against the challenge from step 1, so the ticket is useless to any other app. The response carriesaccessTokenandrefreshTokenin the body, which the app stores in the secure store and refreshes like any other session.
The app handles each status of the exchange:
| Status | What the app does |
|---|---|
signed_in | Stores the tokens and opens the lobby. |
requires_2fa | The existing two-factor screen, with the tempToken. |
complete_signup | The Finish your profile screen (username, email if the provider gave no verified one, marketing opt-in), which calls POST /auth/external/complete-signup with X-Auth-Client: mobile. |
link_required | The login screen with a notice ("An account with a***@example.com already exists. Sign in to link your Google account."). After the password (and 2FA) step the app asks "Link your Google account … to this account?" and, on yes, calls POST /auth/external/link-ticket with the PKCE verifier the ticket is bound to. |
pending_approval, email_verification_required | A message; the account exists but cannot sign in yet. |
Errors (the player cancelled, the provider refused, the link expired) show a plain-language message. Closing the browser is not an error.
Linking and re-authenticating start from a signed-in app, but the system browser carries no session. So the app first calls POST /auth/external/<provider>/start-token { intent, appRedirectUri, appCodeChallenge } with its bearer token. The server returns a one-time startToken (valid 60 seconds, stored hashed, bound to that player, redirect URI and challenge), which the app adds to the start URL as startToken=. The token is not a sign-in code: the exchange endpoint rejects it.
The redirect allowlist
The server only sends a sign-in result to a deep link it knows. poker://auth/callback is always allowed. To add more (for example the deep link of a white-label build), open Settings › Login Providers and add the exact URI under Mobile redirect allowlist (Allowed redirect URIs). Matching is exact: a trailing slash, a query string or another scheme is refused (APP_REDIRECT_NOT_ALLOWED). Only the app’s own custom scheme, or an https:// link on your Site URL’s host, can be added; http, https on any other host, and browser schemes (javascript, data, file, blob, ws/wss and similar) are refused.
For a white-label build, change the app’s scheme in packages/mobile/app.json, change MOBILE_REDIRECT_URI in packages/mobile/src/api/external-auth-contract.ts to match, and add the URI to the allowlist. The provider consoles never see this URI: the provider only redirects to the server’s own callback URL (<site>/api/v1/auth/external/<provider>/callback), which is the one you register with Google, Discord and the others.
Sign in with Apple (App Store requirement)
App Store guideline 4.8 requires an app that offers Google, Discord or any other third-party sign-in to also offer an equivalent privacy-preserving login; Sign in with Apple is the one this app offers. The app therefore shows the Apple button first on iOS whenever any other provider is shown. If another provider is enabled and Apple is not, an iOS development build logs a warning and App Review will reject the build: enable the Apple provider in Admin > Plugins > Social Login first.
- On iOS the Apple button uses the system sheet (
expo-apple-authentication) when the provider’s descriptor hasnativeCredential: 'apple'. The app posts{ credential: { identityToken, fullName }, intent }toPOST /auth/external/apple/credential;fullNameis{ givenName, familyName }and only present the first time Apple sends a name. While a player is signed in the same call withintent: 'link'links the Apple account (bearer token, no browser). - The server checks the identity token with the bundle id (
com.pokerengine.appunless you changed it) as the audience: enter it under iOS bundle IDs on the Apple card, or the descriptor has nonativeCredentialand the app falls back to the browser. Each identity token signs in once. The credential must carrynonce, the raw value whose SHA-256 hex the app passed to Apple, and the token’snonceclaim must be that hash: a request without a nonce, or a token issued without one, is refused. The app creates a fresh nonce for every sign-in. app.jsonsetsios.usesAppleSignIn: trueand lists theexpo-apple-authenticationplugin, which adds the Sign in with Apple entitlement. Enable the Sign in with Apple capability on the app’s identifier in the Apple Developer account before building.- On Android there is no system sheet: Apple signs in through the browser flow above when the Apple provider has a browser flow, and is hidden otherwise.
Expo development builds and production builds
expo-crypto and expo-apple-authentication ship native code, so the social buttons need a development build or a store build. They do not work in Expo Go.
Development build (npm run build:dev, expo start --dev-client) | Production build (build:preview, build:production) | |
|---|---|---|
| Callback link | poker://auth/callback (the scheme in app.json) | the same |
| API URL | EXPO_PUBLIC_API_URL must be reachable from the phone and be the Site URL the providers have registered for their callback, for example a tunnel to your dev server. A provider will not redirect to localhost. | your production https:// API |
| Apple | works on a physical device and on a simulator signed in to an Apple ID | works once the capability is enabled and the build is signed |
| Providers | each provider’s console needs the server’s callback URL for that API host | the production callback URL |
Use intent=test on the web admin page (Social Login > Test sign-in) to check a provider before testing it on a phone.
Testing
Unit tests for the PKCE helper, callback parsing, status routing, the Apple ordering rule and the API calls are in tests/mobile-external-auth-*.test.ts and run with npm run test:run. The start-token endpoint has server tests in src/api/routes/external-auth-start-token.routes.integration.test.ts. packages/mobile/e2e/social-login.test.ts holds Detox specs. The browser round trip and the Apple sheet need a real device or simulator and a real provider.