How auth provider connections work
Connect your auth provider once and every sign up, sign in, sign out and deleted account reaches Mode Metrics on the right person, with no code in your app.
Open Metrics, then Systems, pick your provider under Sign ins and accounts and connect. Mode shows an address for your provider to send its webhooks to. Each delivery is checked against the secret or token you gave the connection, the way your provider signs it, and anything that fails the check is refused.
The person is your provider's own user id. When the Mode snippet reads the signed in user from the same provider's library on your pages, it identifies with that same id, so a sign up your provider reports and the visits before it are one person. Organizations become a group of type organization.
| Event | When |
|---|---|
$signed_up | Your provider made the user |
$signed_in | A session started or a login succeeded |
$signed_out | A session ended, where your provider reports it |
$sign_in_failed | A login failed for a known user (Auth0) |
$account_deleted | The user was deleted |
$organization_created | An organization was made, by its creator |
$member_invited | Someone was invited to an organization, by the person who invited |
$member_joined, $member_removed | A person joined or left an organization |
Each event carries $source, naming the provider, and method where the provider says how the person signed in. The person gets auth_provider, email_verified and signed_up_at. Email addresses, names and phone numbers are never sent to Mode.
Clerk
Clerk signs its webhooks, and Mode checks each one with the endpoint's signing secret.
- In Mode, connect Clerk with any name and copy the address. You add the secret in the last step.
- In the Clerk dashboard open Configure, then Webhooks, and add an endpoint with the address.
- Subscribe to the
user,session,organization,organizationInvitationandorganizationMembershipevents. - Copy the endpoint's Signing Secret (
whsec_...) and paste it into the connection as its signing secret.
| Clerk event | Mode event |
|---|---|
user.created | $signed_up |
session.created | $signed_in |
session.ended, session.removed, session.revoked | $signed_out |
user.deleted | $account_deleted |
organization.created | $organization_created |
organizationInvitation.created | $member_invited, when Clerk names who invited |
organizationMembership.created, .deleted | $member_joined, $member_removed |
Auth0
An Auth0 log stream sends every sign up, login and logout, with a token you give both Auth0 and Mode.
- In Mode, connect Auth0. Mode fills in a random token. Copy it and the address before you connect.
- In the Auth0 dashboard open Monitoring, then Streams, and create a Custom Webhook stream.
- Set Payload URL to the address and Authorization Token to
Bearerfollowed by the token. - Set Content Type to
application/jsonand Content Format to JSON Array, then save.
| Log type | Mode event |
|---|---|
ss | $signed_up |
s | $signed_in |
slo | $signed_out |
f, fp, fu, fcoa, fco, fcpro | $sign_in_failed with reason |
sdu | $account_deleted |
A login into an Auth0 organization puts the event in that organization's group.
Supabase Auth
A database webhook on auth.users sends sign ups, sign ins and deletions, and never sits in the path of a sign in.
- In Mode, connect Supabase Auth. Mode fills in a random token. Copy it and the address before you connect.
- In the Supabase dashboard open Database, then Webhooks, and create a webhook on the
authschema'suserstable for Insert, Update and Delete. - Pick HTTP Request, set the method to
POSTand the URL to the address. - Add the header
AuthorizationwithBearerfollowed by the token, then create it.
| Change | Mode event |
|---|---|
| A row inserted | $signed_up |
last_sign_in_at changed | $signed_in |
| The email confirmed | email_verified on the person |
| A row deleted | $account_deleted |
Auth Hooks
You can count sign ins from an HTTPS Custom Access Token hook instead, which also tells Mode the sign in method. Add the hook in Authentication, then Hooks, with the address, and paste the hook's secret (v1,whsec_...) into the connection as its auth hook secret. Mode answers the hook at once with your claims unchanged, so it never alters or slows a sign in. A refreshed token is not counted as a sign in. A Before User Created hook sends $signed_up the same way. Use the hooks or the database webhook for sign ins, not both.
Firebase Authentication
Firebase has no webhooks, so a short Cloud Function forwards each sign up, sign in and deletion, signed with a secret you give both the function and Mode.
- In Mode, connect Firebase Authentication. Mode fills in a random secret. Copy it and the address before you connect.
- Add the function below to your Firebase functions, set
MODE_AUTH_URLto the address andMODE_AUTH_SECRETto the secret, and deploy. - In Authentication, then Settings, then Blocking functions, pick
modeBeforeCreatefor Before account creation andmodeBeforeSignInfor Before sign in.
const { beforeUserCreated, beforeUserSignedIn } = require('firebase-functions/v2/identity') const functions = require('firebase-functions/v1') const crypto = require('crypto') // Sends one event to Mode, signed by Standard Webhooks. Never blocks a sign in. async function send(type, user, id, at, method) { const key = Buffer.from(process.env.MODE_AUTH_SECRET.replace('whsec_', ''), 'base64') const created = user.metadata && user.metadata.creationTime const body = JSON.stringify({ id, type, method, time: new Date(at).toISOString(), tenantId: user.tenantId, user: { uid: user.uid, emailVerified: !!user.emailVerified, creationTime: created ? new Date(created).toISOString() : undefined } }) const ts = String(Math.floor(Date.now() / 1000)) const sig = crypto.createHmac('sha256', key).update(`${id}.${ts}.${body}`).digest('base64') try { await fetch(process.env.MODE_AUTH_URL, { method: 'POST', body, signal: AbortSignal.timeout(3000), headers: { 'content-type': 'application/json', 'webhook-id': id, 'webhook-timestamp': ts, 'webhook-signature': `v1,${sig}` } }) } catch (e) {} } exports.modeBeforeCreate = beforeUserCreated(e => send('user.created', e.data, e.eventId, e.timestamp, e.additionalUserInfo && e.additionalUserInfo.providerId)) exports.modeBeforeSignIn = beforeUserSignedIn(e => send('user.signed_in', e.data, e.eventId, e.timestamp, e.additionalUserInfo && e.additionalUserInfo.providerId)) exports.modeUserDeleted = functions.auth.user().onDelete((user, ctx) => send('user.deleted', user, ctx.eventId, ctx.timestamp))
The function returns nothing, so Firebase lets every sign up and sign in through unchanged. Firebase reports no sign outs.
WorkOS
WorkOS signs its webhooks, and Mode checks each one with the endpoint's secret.
- In Mode, connect WorkOS with any name and copy the address. You add the secret in the last step.
- In the WorkOS dashboard open Webhooks and create an endpoint with the address.
- Pick the
user,session,organization,invitationandorganization_membershipevents. - Copy the endpoint's secret and paste it into the connection as its webhook secret.
| WorkOS event | Mode event |
|---|---|
user.created | $signed_up |
session.created | $signed_in, in its organization |
session.revoked | $signed_out |
user.deleted | $account_deleted |
invitation.created | $member_invited |
organization_membership.created, .deleted | $member_joined, $member_removed |
organization.created, .updated | The organization's name on its group |
Deliveries and status
Each connection shows its last deliveries, the person each one landed on and whether anything waits to be read again.
A delivery Mode can't pass on yet is kept for up to 30 days and read again within the hour, under the same ids, and the connection shows failing with the reason. Read them again does it straight away. A delivery that fails the signature check is answered 400, which your provider's own delivery log shows. Check that the address and the secret are the ones on the connection.
API and MCP
Auth providers are connected systems, so the same tools and routes connect and manage them. An agent uses connect_system with system set to clerk, auth0, supabase, firebase or workos, then connected_systems, set_system, system_deliveries, system_kept, replay_system and disconnect_system. Over HTTP the routes are under /v1/metrics/systems, as Connected systems lists. They take an MCP key with read and write access from Metrics, Setup, MCP server, or an org or personal key with Metrics MCP access. A Metrics secret key from Metrics, Setup, Keys is refused.
curl -X POST https://app.gotmode.com/v1/metrics/systems \ -H "Authorization: Bearer YOUR_MCP_KEY" \ -H "Content-Type: application/json" \ -d '{"system": "clerk", "name": "clerk", "credentials": {"signing_secret": "whsec_..."}}'