Skip to content

Firebase emulator guide

Tri edited this page Mar 17, 2023 · 4 revisions
  1. Install: npm i -g firebase-tools
  2. Open terminal and run: firebase login and complete login step

Setup with project:

  1. Open terminal and cd to folder that contains the project, or if you use VSCode, just open project with VSCode
  2. Run command: firebase init
  3. Use arrow key to move, and press space at emulators to choose, press enter to coninue
  4. Choose Emulators
  5. Choose Authentication Emulator
  6. Add env: FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099 for firebase to know to use emulator
  7. Complete other steps

Start emulator:

  1. Run command firebase emulators:start to start emulator of current firebase project

Get auth token:

  1. Go to http://127.0.0.1:4000/auth and add user with email, phone, password
  2. Use this curl and change data like above to get token:
curl --location -g 'http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[API_KEY]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "",
    "password": "",
    "returnSecureToken": true
}'