Skip to content

Social sign-in internals

Internals of social sign-in. For the partner guide, see Sign users in with Google; for the rest of AuthAPI, see AuthAPI internals.

Status (October 2026)

Everything on this page is on the staging branches of AuthAPI, CoreAPI, tellyid and PlatformConsole, and Google is configured as a provider on the staging environment only. Production has no provider configured, so its sign-in page shows no "Continue with Google" button. Microsoft is wired in the code (any provider key works) but no Microsoft provider is configured; the sign-up wizard's Microsoft button is a disabled placeholder.

Social sign-in lets a person use an external identity provider (today Google) instead of a password. Zitadel stays the only credential store and brokers the provider. AuthAPI runs the flow and decides which PlayTelly identity the provider account belongs to, and tellyid shows the buttons and screens. AuthAPI keeps no server-side state for the flow: the data that has to survive the round trip is carried in short-lived signed tokens.

Code: AuthAPI internal/handlers/idp.go, internal/services/idp.go, internal/services/zitadel_idp.go, internal/config/config.go (loadSocialConfig); tellyid src/components/Auth.tsx, src/components/SocialLink.tsx, src/components/SignupWizard.tsx, src/lib/signupProof.ts, src/lib/arrival.ts; CoreAPI domain/tenancy/services/org_service.go, token_approval.go, approval_token.go.


1. Endpoints

All four are public routes on AuthAPI (internal/routes/routes.go).

Method Path What it does
GET /api/v1/auth/idp/providers {"providers": ["google"]}: the enabled provider keys, sorted. Empty when the feature is off. tellyid shows a button only for the keys listed here.
GET /api/v1/auth/idp/:provider/start?redirect_uri=…[&flow=signup] Starts a Zitadel IdP intent and answers 302 to the provider. Sets a short-lived HttpOnly idp_nonce cookie (10 min, path /api/v1/auth/idp) that binds the callback to this browser. 404 PROVIDER_NOT_FOUND for an unknown or disabled provider, 400 REDIRECT_NOT_ALLOWED when redirect_uri is not on an allowed origin.
GET /api/v1/auth/idp/callback?state=…&id=…&token=…[&user=…] Where Zitadel sends the browser back. Always ends in a redirect: signed in (cookies set), the link screen, the sign-up wizard with a proof, or the sign-in page with idp_error=<code>.
POST /api/v1/auth/idp/link/confirm Body {link_token, password}. First use of a provider account: checks the identity's password, links the provider account and signs in. Answers {redirect_uri, user, org} and sets the auth cookies; 403 LINK_INVALID when the link token has expired.

The sign-up proof is consumed by the existing self-signup call (see §4); there is no separate endpoint for it.


2. Sign-in flow

sequenceDiagram
    participant B as Browser (tellyid /auth)
    participant A as AuthAPI
    participant Z as Zitadel
    participant G as Google
    B->>A: GET /auth/idp/google/start?redirect_uri=<app>
    A->>A: check redirect origin, sign state (10 min), make nonce
    A->>Z: POST /v2/idp_intents {idpId, successUrl, failureUrl}
    Z-->>A: authUrl (points at Google)
    A-->>B: 302 authUrl + Set-Cookie idp_nonce
    B->>G: consent / account chooser
    G-->>Z: authorization code
    Z-->>B: 302 /auth/idp/callback?state&id&token[&user]
    B->>A: GET /auth/idp/callback (with idp_nonce cookie)
    A->>A: verify state + nonce
    alt provider account already linked (user=… present)
        A->>Z: POST /v2/sessions (user + idpIntent)
        A->>A: completeLogin: org, account-state and license gates
        A-->>B: 302 <app> + auth cookies
    else not linked yet
        A->>Z: retrieve intent: subject, e-mail, email_verified
        A->>A: find identity by verified e-mail
        A-->>B: 302 tellyid /auth/link#link_token=…&email=…
    end

Rules, as implemented in SocialCallback:

  • Sign-in only matches existing identities. A provider account whose e-mail has no PlayTelly identity gets idp_error=no_account ("Ask your administrator to invite you").
  • First use links by verified e-mail plus the password. If the provider did not verify the e-mail, the result is email_unverified. Otherwise AuthAPI finds the identity with that e-mail and hands tellyid a link token (10 min) in the URL fragment, so it never reaches a server log or a Referer header. tellyid's /auth/link screen ("Confirm it's you") reads it, removes it from the address bar and asks for the account's password once. POST /auth/idp/link/confirm checks the password with Zitadel, adds the IdP link (POST /v2/users/{id}/links) and signs the person in.
  • After that, the provider's stable subject id is what counts. Zitadel recognises the linked account and returns user=… on the callback. The e-mail is not looked at again, so a later e-mail change at the provider does not matter.
  • Home org, no company code. A provider sign-in uses the org the identity belongs to. The person does not type a company code.
  • Same gates as password login. Both paths end in completeLogin, so pending or disabled orgs, disabled, pending or invited accounts and an expired on-prem license are refused in the same way.

Error codes

The callback redirects to <tellyid>/auth?idp_error=<code>[&redirect_uri=…]. tellyid turns the code into a message or a status screen.

Code Meaning
no_account No identity has the provider's e-mail address
email_unverified The provider did not verify the e-mail
account_exists Sign-up flow: this e-mail already has an account, sign in instead
provider_failed Cancelled, or the provider or Zitadel reported a failure
state_invalid State expired, or the callback came to a different browser (nonce mismatch)
account_pending / account_disabled / account_invited Account-state gate (status screen)
org_pending / org_disabled / org_not_found Org gate (status screen for the first two)
license_expired On-prem license guard
server_error Anything else

tellyid adds one code of its own, link_expired, when the link confirmation answers LINK_INVALID.


3. Invited members

An admin invites someone, which creates an account in state invited, and the invitation is still unused. If that person's first "Continue with Google" carries a provider-verified e-mail that equals the invited address (case-insensitive), AuthAPI (acceptInviteWithProvider):

  1. links the provider account in Zitadel,
  2. sets the account active and clears password_change_required,
  3. deletes the invitation's magic link,
  4. creates the Zitadel session and signs the person in through completeLogin.

The person never sets a password and never sees the link screen. The invitation e-mail already proved they own the mailbox, and the provider has just proved it again for the same address. Unchanged:

  • an active account still confirms its password once on first link;
  • disabled and pending accounts are never activated by a provider;
  • a provider e-mail that differs from the invited address never matches.

4. Sign up with Google

Self-signup (see AuthAPI internals: account and organization states) normally proves the applicant's e-mail with a code sent by mail. "Sign up with Google" replaces that step with a proof from the provider. Nothing is created at the provider step: the platform approval stays in place.

sequenceDiagram
    participant W as tellyid sign-up wizard
    participant A as AuthAPI
    participant G as Google (via Zitadel)
    participant C as CoreAPI
    W->>A: GET /auth/idp/google/start?redirect_uri=<wizard URL>&flow=signup
    A->>G: IdP intent
    G-->>A: callback (verified e-mail, subject)
    A->>A: refuse if unverified or if the e-mail already has an account
    A-->>W: 302 <wizard URL>#signup_proof=…&email=…&given_name=…&family_name=…
    W->>W: skip the code step, prefill and lock the e-mail
    W->>C: POST /api/v1/tenancy/organizations/self-signup {…, idp_proof}
    C->>A: POST /internal/platform/orgs/self-signup {…, idp_proof} (PSK)
    A->>A: verify proof (signature, 30 min expiry, e-mail = form e-mail)
    A-->>C: 201 {org, idp_verified: true}
    C-->>W: 201 {approval: "pending" | "approved"}
  • The proof is a signed token valid for 30 minutes and comes back in the URL fragment. The wizard reads it once and removes it. The wizard's own query string (?plan=…&product=…&source=…) survives the round trip.
  • AuthAPI refuses a wrong, expired or mismatched proof (400); it never falls back to "unverified". It stores the provider id and subject on the pending org (orgs.applicant_idp_id, applicant_idp_subject).
  • CoreAPI fails closed. It skips its own e-mail-code check only when idp_proof is present, and it then requires AuthAPI to answer idp_verified: true. If AuthAPI does not confirm the proof, CoreAPI deletes the application it just created and refuses the request. An older AuthAPI therefore cannot let an unverified e-mail through.
  • CoreAPI records signup_method (google or email) on the application (org_applications).

On approval (PUT /internal/platform/orgs/:orgId/status {"status":"active"}, triggered by a platform admin or by an approval token), AuthAPI creates the Zitadel org and its admin in one call (POST /v2/organizations). For a Google sign-up, the admin is created already linked to the provider account (idpLinks), with a verified e-mail and no password. No temporary password is generated and password_change_required is false. CoreAPI then creates the local admin, the default workspace and the plan as usual, and sends the welcome e-mail without a password. That e-mail tells the person to choose "Continue with Google" on the sign-in page. Their first sign-in goes straight through, with no link confirmation, because the link already exists.


A sign-up link pre-approves a self-signup, so nobody has to watch the approvals queue (for events, partners and campaigns). Platform staff create the links in PlatformConsole → Sign-up links, which calls the CoreAPI routes below. Each route requires the platform permission platform:org:manage.

Method Path Notes
POST /api/v1/tenancy/organizations/approval-tokens {modules[] (required), plan?, source?, channel?, ttl_hours? (default 72), max_uses? (default 200), trial_days? (0-365)}. Answers 201 {token, signup_url, approval_token}. The token appears only in this answer.
GET /api/v1/tenancy/organizations/approval-tokens Status (active, revoked, expired, used up), uses and who used it. Never the token itself. ?kind=install / ?kind=all include self-hosted install tokens.
POST /api/v1/tenancy/organizations/approval-tokens/:id/revoke 204. Stops new approvals; orgs already approved stay approved.

The token. 16 Crockford base32 characters in four groups (XXXX-XXXX-XXXX-XXXX). CoreAPI stores only its hash and a hint (the last four characters). Input is normalised: case, spaces and dashes are ignored, O is read as 0, and I/L as 1.

Where it travels. signup_url is <tellyid>/auth?signup=1#approval=<token>. The token sits in the URL fragment, which a browser never sends to a server. tellyid (src/lib/arrival.ts) captures it on the first page load into sessionStorage, removes it from the address bar, and sends it as approval_token with the self-signup. tellyid also sets <meta name="referrer" content="same-origin">. The token is cleared once the application is sent.

What redemption does (tryTokenApproval). The application is first created as usual. Only an e-mail already verified by the code or by a Google proof gets that far. CoreAPI then spends one use of the token in a single atomic update. If the token is valid:

  1. the org's apps are replaced by the token's modules, not by what the link asked for;
  2. the token's plan and trusted source are written on the application;
  3. the normal approval runs (Zitadel org and admin, local admin, default workspace, plan, welcome mail);
  4. if trial_days > 0, the org gets trial_expires_at. A scheduled job disables orgs whose trial has ended.

If the approval fails, the use is given back. An invalid, expired, used-up or revoked token never fails the sign-up: the application stays pending for staff, and approval_note says why. The self-signup answer carries approval: approved | pending. When a Google sign-up is approved this way, tellyid starts "Continue with Google" right away and the person lands signed in on the home page.

Source tracking. The token is the trusted record of where a sign-up came from, because only staff can create one. What the browser reports is kept beside it as untrusted hints for reporting: utm_source, utm_medium and utm_campaign, the link's source, the referrer host only, and the landing path without its query or fragment. Values are trimmed and stripped of control characters. They are stored on org_applications (source, link_source, utm_*, referrer_host, landing_path, approval_token_id). CoreAPI never decides anything based on them.


6. Configuration

AuthAPI environment

Variable Meaning
AUTHAPI_IDP_PROVIDERS Comma-separated key:<zitadel idp id> pairs, e.g. google:<id> or google:<id>,microsoft:<id>. The key is the name in the URL (/auth/idp/google/start) and in the providers list. Empty = feature off (no buttons, start answers 404). A malformed entry stops AuthAPI at boot.
AUTHAPI_PUBLIC_URL How the browser reaches AuthAPI. The callback URL handed to Zitadel is <AUTHAPI_PUBLIC_URL>/api/v1/auth/idp/callback.
AUTHAPI_REDIRECT_ORIGINS Origins allowed as redirect_uri (open-redirect guard). Default: the CORS origins plus the frontend URL.

The state, link and proof tokens are signed with a key derived from the refresh-token secret, so no new secret is needed. The idp_nonce cookie uses the same cookie domain as the auth cookies.

CoreAPI builds signup_url from tellyid's public address, which it reads from AUTHAPI_FRONTEND_URL in its own environment. Without it, signup_url comes back empty.

Adding a provider in Zitadel

  1. At the provider (for Google, an OAuth client of type Web application), register Zitadel's callback as the redirect URI: https://<zitadel host>/idps/callback. Request only the basic scopes openid, profile and email.
  2. In the Zitadel console, add the provider at instance level with the client id and secret. Allow linking, and leave account creation and automatic creation/linking off: AuthAPI decides who gets linked. Activate the provider in the login policy.
  3. Copy the provider's id from Zitadel into AUTHAPI_IDP_PROVIDERS (google:<id>), set AUTHAPI_PUBLIC_URL, and restart AuthAPI.
  4. Check that GET /api/v1/auth/idp/providers lists the key. tellyid then shows "Continue with Google" on the sign-in page and enables "Sign up with Google" in the wizard.

Use a separate provider client per environment, each pointing at that environment's Zitadel callback. For public use, Google requires the consent screen to be published with privacy-policy and terms links on a domain you own. While the app is in testing mode, only listed test users can sign in.