Aller au contenu

Migrate from Firebase to Auth0

Ce contenu n’est pas encore disponible dans votre langue.

This guide covers moving users from Firebase to Auth0: what carries over and what doesn’t, how their passwords and second factors are handled, and the commands to run. It sticks to what is specific to this pair. The export guide for Firebase and the import guide for Auth0 cover each side in full, including a rehearsal with synthetic users.

Firebase to Auth0
PasswordsNot carried over: only Firebase can verify its modified scrypt. Users reset their password.
Second factorsSMS enrollments carry over. The rest need re-enrollment.
User IDsThe Firebase uid is kept as source_id, and Auth0 adds its connection prefix to it.

The Firebase export leaves behind:

  • Linked sign-in providers (only the email and phone number they carry are kept)
  • Timestamps
  • Tenants (only the project’s default tenant is read)
  • Anonymous and custom-token users, which the export skips
  • iamigrate installed (see Installation).
  • A Google service account key for the project, with a role that can list users such as Firebase Authentication Admin, or an OAuth2 access token.
  • Auth0. An Auth0 tenant (use a development tenant for the rehearsal), a database connection to import into, the MFA factors you intend to import enabled under Security → Multi-factor Auth, and Management API credentials. The import guide walks through it.
Terminal window
export FIREBASE_PROJECT_ID=acme-prod
export GOOGLE_APPLICATION_CREDENTIALS=./service-account.json
iamigrate export --source firebase --out ./export/

The export is a snapshot: users created, and passwords changed, after it aren’t in it, so plan a freeze or a final re-export before cutover. Check export/manifest.json for skipped_records, because the command exits with status 0 even when users are skipped, and for the per-algorithm counts.

Firebase hashes passwords with a modified scrypt that depends on two secrets shared by the whole project, and only Firebase can verify it. Auth0 does accept scrypt, but not Firebase’s modified variant, which has no keylen or power-of-two cost for Auth0 to use, so those users fail with TRANSLATION_ERROR. Passwords can’t be carried over, whatever you pass to the export.

That makes the project’s hash parameters pointless for this move, so you can skip step 2 of the Firebase export guide. Drop every password from the export, so the users are created without one:

Terminal window
gunzip -c export/users.cmf.jsonl.gz \
| jq -c '.password = null' \
| gzip > export/users.ready.cmf.jsonl.gz

Users who only sign in with Google, Apple or a phone number have no password to lose. The others need to set a new password. Send them a password reset email, or let them use Forgot password at first login.

Read the later steps from export/users.ready.cmf.jsonl.gz.

Second factor in the exportOn Auth0
SMS (portable unless Firebase returned the number masked)Imported as a phone factor. Needs an E.164 number (+12125550001) and the Phone Message factor enabled.
TOTP (flagged non-portable: Firebase never returns the secret)Not imported. The user is created and listed in the report for follow-up, and enrolls again after signing in.
  • Email is required. Auth0’s bulk import needs an email, so a user without one isn’t sent and is reported as TRANSLATION_ERROR. Firebase users who sign in with a phone number only have no email.
  • Usernames. If the database connection has Requires Username turned on, every user needs a username, and Firebase users have none. Leave that option off, or add usernames to the CMF records first.
  • Metadata. Custom claims arrive as app_metadata. Auth0 takes app_metadata and user_metadata as they are, and validate reports a top-level app_metadata key Auth0 reserves, such as email or blocked.
  • Names. Firebase’s displayName arrives as profile.name and is copied to Auth0’s name.

Set the target in the scaffolded mapping, then check the export against what the target can import. validate makes no network calls:

Terminal window
iamigrate map --target auth0 --mapping ./export/mapping.yaml --connection-id con_XXXXXXXXXXXXXXXX
iamigrate validate --in ./export/users.ready.cmf.jsonl.gz \
--mapping ./export/mapping.yaml --target auth0

Add --connection-config connection.json (a GET /connections/{id} response) to check usernames against the connection’s own rules.

Fix every reported problem at the source, or in the CMF records, and run it again until it comes back clean. Review mapping.yaml too: custom metadata keys are flagged under manual_steps for you to place, rather than guessed at.

Do a rehearsal first. Follow the Auth0 import guide with a fixture that holds the same hash algorithms and second factors as your users, against a disposable target, and sign in as a few of the users (see Generate test fixtures).

For the real run, point iamigrate at Auth0:

Terminal window
export AUTH0_DOMAIN=your-tenant.us.auth0.com
export AUTH0_CLIENT_ID=... # a Machine-to-Machine application with the scopes the import guide lists
export AUTH0_CLIENT_SECRET=...

Split off a small canary, import it, and check the result before you import the rest:

Terminal window
gunzip -c export/users.ready.cmf.jsonl.gz | head -n 100 | gzip > export/canary.cmf.jsonl.gz
gunzip -c export/users.ready.cmf.jsonl.gz | tail -n +101 | gzip > export/rest.cmf.jsonl.gz
iamigrate import auth0 \
--in ./export/canary.cmf.jsonl.gz \
--mapping ./export/mapping.yaml \
--connection-id con_XXXXXXXXXXXXXXXX \
--report ./export/canary-report.json

Sign in as a few canary users, then import the rest:

Terminal window
iamigrate import auth0 \
--in ./export/rest.cmf.jsonl.gz \
--mapping ./export/mapping.yaml \
--connection-id con_XXXXXXXXXXXXXXXX \
--report ./export/rest-report.json

The command exits with status 0 even when users fail. Always read the reports: each failed user is listed under failed with a code, and the follow-up lists (requires_password_reset, requires_reenrollment and so on) say who needs to hear from you. The import guide explains each code.

Reconcile the file with the live target. It reports users missing from it and drift in the fields it can read back:

Terminal window
iamigrate diff auth0 --in ./export/users.ready.cmf.jsonl.gz --mapping ./export/mapping.yaml

There is no password to prove here, so check the reset path instead: make sure a test user can set a new password on Auth0 and sign in.

Auth0 builds the user_id as auth0|<source_id>, so a Firebase uid abc123 becomes auth0|abc123. If your applications reference users by the old ID, keep that mapping.

  • Freeze changes in Firebase, re-export, and import the final file.
  • Reconnect what the export doesn’t carry: the linked sign-in providers such as Google or Apple, which users have to link again. Firebase has no organizations or roles, but if you keep them elsewhere, Auth0 can take them from files you write (see Organizations, roles and groups). Then point every application at Auth0.
  • Tell users what to expect. They need to set a new password. A second factor that didn’t move has to be enrolled again.
  • Clean up the rehearsal. Delete the rehearsal users from User Management → Users, or delete the connection and recreate it, before you import real ones. Users deleted any other way can linger in Auth0’s user store and cause DUPLICATED_USER later.