Cannot connect Admin SDK to firebase authentication emulator

Viewed 290

I am trying to connect the Admin SDK to the firebase authentication emulator. But for some reason , the Admin SDK keeps connecting to the live online project. The firebase authentication emulator is running though. I tried setting setting the FIREBASE_AUTH_EMULATOR_HOST environment variable GOOGLE_APPLICATION_CREDENTIALS = key.jsonand the project ID byadmin.initializeApp({ projectId: "YOUR_PROJECT_ID" };. It didn't work. I tried downloading the key from Google Cloud Console using a service account and setting the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to that key. But the admin SDK still uses the live project. How do I connect the admin SDK to the local firebase authentication emulator?

1 Answers

You can connect the admin SDK by setting an environment variable.

eg: Using the command line:

export FIREBASE_AUTH_EMULATOR_HOST='localhost:9099'

Using node, you can also set this with:

process.env.FIREBASE_AUTH_EMULATOR_HOST='localhost:9099'
Related