Mobile Apps

Firebase Authentication: Sign-In Methods, Account Linking and Security

Firebase Authentication is quick to add but its early decisions are hard to undo. Here is how we choose sign-in methods, link accounts so one person has one login, use tokens and custom claims safely, and harden sign-in against abuse.

Illustrated icons for a MySQL database, REST APIs, third-party integrations and cloud deployment

Adding sign-in with Firebase Authentication takes an afternoon. Getting it right takes longer: deciding which sign-in methods to offer, what happens when the same person signs in with Google on Monday and with email on Tuesday, how your server knows who is calling, and how to stop SMS fraud or account takeover. These decisions are hard to change once real users have accounts, so they are worth making deliberately at the start.

Authentication is the first thing we design in any Firebase development project, for web and mobile apps alike. If you are still deciding whether Firebase suits your product at all, our article on what Firebase costs and when it fits covers that. This one assumes you are using it and focuses on sign-in.

Choosing Sign-In Methods

Firebase Authentication supports a wide range of providers. Each has a different trade-off between convenience, cost and support burden:

  • Email and password. Universally understood and free, but it brings password resets, weak passwords and credential-stuffing attacks. Turn on a password policy and email verification, and check emailVerified wherever it matters.
  • Email link (passwordless). Users receive a sign-in link instead of choosing a password. Convenient, though it depends on email arriving quickly. Mobile apps that used email links previously relied on Firebase Dynamic Links, which Google has shut down, so older apps need their link handling updated.
  • Phone number (SMS). Familiar in many markets and good for apps without email, but every message costs money, and SMS sign-in is a target for fraud that triggers large volumes of messages to premium numbers. Restrict the regions you allow SMS to, and protect the flow with reCAPTCHA and App Check.
  • Google, Apple, Microsoft, Facebook, GitHub and others. Federated sign-in removes passwords from your app entirely. Note that Apple's App Store rules require apps offering third-party social sign-in to also offer an equivalent privacy-focused option, which in practice means Sign in with Apple on iOS.
  • Anonymous accounts. Let people use the app before signing up, then convert the account later without losing their data.
  • Custom tokens. If users already exist in another system, your server can verify them and mint a Firebase custom token with the Admin SDK, so Firebase security rules work without migrating the user base first.

For most consumer apps we suggest one or two federated providers plus email, rather than every option available. Each extra method is another support path and another way for the same person to end up with two accounts.

Account Linking: One Person, One Account

By default, Firebase allows one account per email address. If someone signed up with email and later tries Google with the same address, sign-in fails with an account-exists-with-different-credential error, and the app has to handle it. The usual flow is: tell the user an account already exists, ask them to sign in with the original method, then attach the new credential with linkWithCredential, so either method works afterwards.

  • Email enumeration protection, enabled by default on newer projects, stops Firebase revealing which sign-in methods an email uses. That is good for security, but it means the app cannot simply look up the existing provider and must word its messages carefully.
  • Anonymous upgrades also use linking: when an anonymous user signs up, link the new credential to the anonymous account rather than creating a fresh one, or their data is orphaned.
  • Merging two existing accounts is not automatic. If both already hold data, you need a server-side merge in a Cloud Function, and a rule for which record wins.

Designing these flows up front saves a steady trickle of "I lost my account" support requests later.

Roles, Tokens and Your Own Back End

After sign-in, the client holds a short-lived ID token, valid for an hour, and a long-lived refresh token the SDK uses to renew it. Three practices keep this secure:

  1. Verify tokens on the server. Any API outside Firebase must verify the ID token with the Admin SDK's verifyIdToken on every request, never trust a user ID sent in the request body. Our API development work builds this into the middleware once.
  2. Use custom claims for roles. Claims such as admin or organisationId are set with the Admin SDK, travel inside the token, and can be read in security rules without a database lookup. They are limited to about 1,000 bytes, and change only when the token refreshes, so force a refresh after changing a user's role.
  3. Revoke when it matters. When a user is disabled or a device is lost, revoke their refresh tokens and check revocation on sensitive operations, otherwise an existing ID token remains usable until it expires.

Authentication only proves who someone is. What they can read and write is enforced by security rules, which we covered in our article on Firestore security rules.

Hardening the Sign-In Itself

  • Multi-factor authentication. Firebase supports SMS and authenticator-app (TOTP) second factors, after upgrading the project to Firebase Authentication with Identity Platform. For admin users and apps holding sensitive data, we treat MFA as standard.
  • Blocking functions. Also part of the Identity Platform upgrade, these run before an account is created or a user signs in, so you can reject disposable email domains, restrict sign-up to a company domain or add claims at creation.
  • App Check. Confirms requests come from your genuine app or site, which blunts scripted abuse of sign-up and SMS endpoints.
  • Authorised domains and API key restrictions. The Firebase API key in your app is not a secret, but restricting it to your apps and domains, and pruning the authorised domains list, reduces misuse.
  • Enterprise sign-in. SAML and OpenID Connect providers, and multi-tenancy for B2B products, also require the Identity Platform upgrade, which changes billing to a per-active-user model beyond a free tier.

For regulated apps, our approach to security and trust in a mobile banking app goes further, and an independent security audit before launch is worth considering.

Getting the Client Experience Right

On mobile, use the native SDKs or official plugins for each framework rather than web redirects, so Google and Apple sign-in use the system sheets users trust. We use the FlutterFire plugins in our Flutter app development work and the equivalent packages for React Native and native apps. Keep users signed in across launches, handle expired sessions with a clear prompt, and make account deletion available inside the app, which both app stores now require for apps that let users create accounts.

If you are planning sign-in for a new app, or untangling duplicate accounts in an existing one, tell us which sign-in methods you use and who your users are. We will recommend a setup that is simple for them and safe for you.

Frequently Asked Questions

Which sign-in methods should a new app offer with Firebase?

For most consumer apps, Sign in with Apple and Google plus email covers nearly everyone, and Apple's rules make Sign in with Apple effectively required on iOS when other social logins are offered. Phone sign-in suits markets where email is less common, but it carries SMS costs and fraud risk. Fewer methods mean fewer duplicate accounts.

Can we move existing users into Firebase Authentication without resetting passwords?

Often, yes. The Firebase CLI and Admin SDK can import users with password hashes from many common algorithms, so people keep their passwords. Where the hash format is unsupported, users can be migrated on their next sign-in, or kept in the old system and signed in to Firebase with custom tokens.

What is Identity Platform and do we need it?

Identity Platform is an upgrade to Firebase Authentication that adds multi-factor authentication, blocking functions, SAML and OpenID Connect providers, multi-tenancy and audit logging. Many consumer apps never need it. Business apps with admin users, enterprise customers or compliance requirements usually do, and it moves billing to a per-active-user model above a free tier.

How do we stop SMS fraud on phone number sign-in?

Limit SMS to the countries where your users actually are, enable App Check so only your genuine app can request codes, keep reCAPTCHA verification on, and set budget alerts so unusual volumes are noticed quickly. If phone sign-in is not essential, offering it only as a second factor rather than a primary method reduces the exposure.

Is it safe that the Firebase API key is visible in our app?

Yes, by design. The key identifies your Firebase project rather than granting access, and data is protected by security rules and server-side token checks. You should still restrict the key to your app identifiers and domains in Google Cloud, keep authorised domains tidy and never put service account credentials in client code.

How We Can Help

Services Related to This Article

The work we do with the technologies discussed above — with pricing, process and real examples on each page.

  • Firebase Development

    Web and mobile backends on Firebase — sign-in, Firestore data, Cloud Functions, push notifications and hosting — built with security rules and cost control from day one.

  • API Development & Integration

    Custom REST and GraphQL API development plus integrations with CRMs, ERPs, payment gateways, shipping carriers and marketing platforms.

  • Security Audit & Penetration Testing

    A structured security review of your website, application and servers — vulnerabilities found and fixed before someone else finds them.

  • Flutter App Development

    Beautiful, fast Flutter apps written in Dart that run natively on Android and iPhone — and on the web — from a single codebase.

In Practice

Case Studies on This Topic

Projects where we put these ideas to work, each with a live demo.

  • Soccer Ball — Northgate Leagues
    • Flutter
    • Firebase Authentication
    • Cloud Firestore

    Mobile App Development

    Community Sports League App on Firebase

    Fixtures, live scores, team chat and sign-ups for 9,000 players — built on Firebase so a volunteer-run league has no servers to look after.

Keep Reading

  • Tablet on a wooden table showing an app dashboard with charts, beside a phone and a white coffee cup

    Adding Kotlin Multiplatform to an Existing Android App

    If you have a mature Kotlin Android app and an iOS app that keeps falling behind, Kotlin Multiplatform lets you share the logic without a rewrite. Here is what moves, which dependencies need replacing and the gradual path we follow.

  • Person typing on a laptop at an outdoor wooden table, with a smartphone, notebook and pen beside it

    Native Device Features in an Ionic App: Camera, Location, Push and Files

    Capacitor gives an Ionic app access to the camera, location, push notifications and the file system, but each comes with permissions, platform differences and store rules. Here is how we make these four features reliable on real devices.

  • Illustration of the same website shown on a desktop monitor, laptop and smartphone, with code and app icons around them

    Turning an Existing Website Into a PWA: What Changes and What It Takes

    Making an existing website installable takes a manifest and a service worker, but doing it without stale pages, confused updates or cached personal data takes more care. Here is what changes on the site and how we plan a safe retrofit.

Let’s Connect

Let’s Build Something Amazing Together

Share your project details and our experts will get back to you within one business day with the best solution — free consultation, no obligation.