Firebase phone OTP
Configure mobile login methods — Firebase phone verification for the Android app, plus server-mediated email and SMS OTP fallbacks.
Firebase phone OTP
The Android app signs salespeople in with a workspace-discovered login screen. You choose which methods are offered: email + password, email OTP, phone + password, or phone OTP verified by Firebase. Firebase gives real phone-number verification without sending SMS from your own infrastructure — Meta-style phones are verified by Google's Identity Toolkit, and the CRM then matches the verified number to the right user.
No google-services.json anywhere The Android app deliberately ships without a google-services.json. At login it fetches your workspace's Firebase options (Web API key, Project ID, App ID, Sender ID) at runtime from the CRM and initializes Firebase on the spot. That is why this integration is configured entirely in the CRM UI — there is no file to rebuild into the APK.
Who this is for
- Admin configuring their workspace's login methods (Settings → Connections → Mobile App).
- Super Admin setting platform defaults for all workspaces.
- Developer wiring a custom build or debugging the login flow.
Difficulty: Advanced · Time: about 20 minutes (plus ~5 minutes in the Firebase console) · Prerequisites:
- The Android app installed for at least one user (see Mobile app setup).
- A Google account to create a Firebase project.
- Optional: tenant SMTP configured for the email fallback (Email & SMTP).
Step 1 — Create the Firebase project
- Go to
console.firebase.google.comand create a project (e.g.your-company-crm). - In Project settings → General → Your apps, click Add app → Android.
- Register the app with package name
com.zodiactech.crm(the app's application ID — it must match exactly; if you also install the demo-flavor APK, registercom.zodiactech.crm.demoas a second app). - Add the SHA-1 of the signing keystore:
- Debug builds: run
gradlew signingReportin the Android project. - Release builds: add the SHA-1 of your release keystore.
- Without the matching SHA-1, phone sign-in fails with an "app not authorized" error before any SMS is sent.
- Debug builds: run
- In Authentication → Sign-in method, enable the Phone provider.
- In Project settings → General, copy the four values you need: Web API key, Project ID, Android App ID (looks like
1:123…:android:abc…) and Sender ID.
"Authorized domains" does not apply here Firebase's authorized-domains list is only used by the web SDK. The Android flow authorizes by app package + SHA-1, so do not chase domain settings if phone auth fails — check the package and SHA-1 instead. An in-app setup guide is also built into the CRM's mobile settings pages, with the same steps.
Step 2 — Turn on Firebase in the CRM
As a client Admin: go to Settings → Connections → Mobile App — this is your workspace's override.
As a Super Admin: go to the platform's Mobile App Login — Platform Defaults page to set defaults every workspace inherits.
Fields:
| Field | Notes |
|---|---|
| Email/password, Email OTP, Phone/password, Phone OTP toggles | Choose which methods the app offers |
| Firebase enabled | Master switch for phone OTP |
| Firebase API key | The Web API key from the console |
| Firebase Project ID | e.g. your-company-crm |
| Firebase App ID | The Android app ID (1:…:android:…) |
| Firebase Sender ID | The messaging sender number |
| OTP length | 4–8 digits (default 6) — for the CRM-generated email/SMS codes |
| OTP TTL (minutes) | 1–60 (default 10) |
Firebase needs all four values Firebase phone OTP is only considered configured when enabled + API key + Project ID + App ID are all present. A half-filled form silently leaves the method off — the app then shows only the other login methods.
Step 3 — Verify where settings apply
Settings resolve in this order:
- Workspace override (
tenants.settings.mobile_auth) — set by the client Admin. - Platform defaults — set by the Super Admin.
At login the app calls GET /api/v1/mobile/auth-config and receives the platform-default method list plus the platform Firebase payload — it is deliberately platform-only, and a client-supplied workspace ID is never trusted. Workspace overrides resolve per-user at login and otp/*, once the account is known. Unconfigured Firebase simply disappears from the method list.
Step 4 — Test the login in the app
- Open the app and enter the phone number of a user in this workspace.
- Choose Phone OTP → the app asks Firebase to send the code (SMS sent by Google, not the CRM).
- Enter the code → the app returns the Firebase ID token to the CRM (
POST /api/v1/mobile/otp/verifywith the token). - The CRM verifies the token server-side against Google's Identity Toolkit (
getAccountInfo), compares the verified phone number to the account, and only then mints a device token (90-day TTL, stored hashed). - Expected result: you land on the Home screen; the device appears under Android App → Devices in the Super Admin panel.
Email OTP and SMS fallback (no Firebase required)
If you prefer not to use Firebase:
- Email OTP is generated by the CRM (HMAC-signed, single-use, TTL above) and mailed via your tenant SMTP — or the platform mailer as fallback.
- SMS OTP sends through your workspace's messaging provider — Twilio, Plivo or a custom provider, configured in messaging settings.
Rate limiting (applies to all OTP methods):
| Limit | Value |
|---|---|
otp/start per identifier |
3 per 10 minutes |
otp/start per IP |
10 per 10 minutes |
| Wrong code attempts | 5 — then the code is destroyed and a new one must be requested |
The limiter is checked before any work happens, so hammering the button does not cause sends or charges. Codes are single-use (burned before the session is minted), and request responses never echo the full phone/email — targets are masked.
Expected result
The app's login screen offers the methods you enabled; with Firebase on, a phone number receives a real verification SMS from Google, and after verifying, the device is signed in and visible to the Super Admin — no google-services.json, no rebuild.
Common mistakes
- Wrong Android package name in Firebase. It must be exactly the app's application ID —
com.zodiactech.crm(demo flavor:com.zodiactech.crm.demo). - Missing SHA-1 for the keystore you actually install with (debug vs release differ).
- Forgetting to enable the Phone provider under Authentication.
- Toggling Firebase on but leaving a field blank — the method stays off until all four values are present.
- Testing with a phone number that belongs to no CRM user — login is refused even if Firebase verified the number (the number must map to an active account in an active workspace).
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Login screen has no phone OTP option | Firebase not fully configured, or method disabled | Fill all four Firebase values and enable the toggle |
| "App not authorized" from Firebase | SHA-1/package mismatch | Add the correct keystore SHA-1 in Firebase settings |
| No SMS arrives | Firebase quota or carrier issue | Check Firebase Auth usage; try email OTP fallback |
| "Too many attempts" style error | Rate limit (3 per number / 10 per IP per 10 min) | Wait 10 minutes |
| OTP email not received | Tenant SMTP problem | See Email or OTP not received |
Workspace rejected errors (NO_WORKSPACE, WORKSPACE_INACTIVE) |
Account's workspace suspended/inactive | Check Businesses (tenants) and the billing state |
Technical details
- Settings model:
MobileAuthSettings(groupmobile_auth), platform defaults + per-tenant override intenants.settings.mobile_auth. - Endpoints:
GET /api/v1/mobile/auth-config,POST /api/v1/mobile/otp/start,POST /api/v1/mobile/otp/verify(accepts a CRM-issued code or a Firebaseid_token),POST /api/v1/mobile/login(email/password + phone/password). - Server-side Firebase verification: Google Identity Toolkit
getAccountInfowith the resolved API key; the phone number returned by Google is compared to the account'sPhoneNumberkey. - Codes: HMAC-SHA256 with a per-code salt, single-use, TTL from
otp_ttl_minutes. - Device tokens: hashed at rest (
DeviceToken::hashToken), 90-day TTL,Authorization: Bearerfor the mobile API. - Pages: tenant
MobileLoginSettingsPage(Settings → Connections → "Mobile App"); Super AdminMobileAuthSettingsPage("Mobile App Login — Platform Defaults").
Related guides
Was this page helpful?
Thanks — noted. ✦