firebase-tools: Error when serving Firebase functions on localhost in combination with Firebase Auth
When serving a Firebase Functions on localhost, Firebase Auth does not work. When running the same code on “the cloud”, it produces no errors.
We initialize the Firebase Admin SDK as follows: admin.initializeApp(functions.config().firebase);
Version info
3.16.0
Steps to reproduce
Run firebase serve --only functions
Create a functions that uses admin.auth().createUser
Expected behavior
It creates a user in the Firebase Authentication module without errors.
Actual behavior
error: { Error: Credential implementation provided to initializeApp() via the "credential" property has insufficient permission to access the requested resource. See https://firebase.google.com/docs/admin/setup for details on how to authenticate this SDK with appropriate permissions.
at FirebaseAuthError.FirebaseError [as constructor] (/Users/frank/Development/planl/formagic-server/functions/node_modules/firebase-admin/lib/utils/error.js:39:28)
at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/Users/frank/Development/planl/formagic-server/functions/node_modules/firebase-admin/lib/utils/error.js:85:28)
at new FirebaseAuthError (/Users/frank/Development/planl/formagic-server/functions/node_modules/firebase-admin/lib/utils/error.js:143:16)
at Function.FirebaseAuthError.fromServerError (/Users/frank/Development/planl/formagic-server/functions/node_modules/firebase-admin/lib/utils/error.js:173:16)
at /Users/frank/Development/planl/formagic-server/functions/node_modules/firebase-admin/lib/auth/auth-api-request.js:523:45
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
errorInfo:
{ code: 'auth/insufficient-permission',
message: 'Credential implementation provided to initializeApp() via the "credential" property has insufficient permission to access the requested resource. See https://firebase.google.com/docs/admin/setup for details on how to authenticate this SDK with appropriate permissions.' },
codePrefix: 'auth' }
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 15 (10 by maintainers)
Commits related to this issue
- Disable emulator features via CLI. Refs #595 and #1252 — committed to matheo/firebase-tools by matheo 5 years ago
Thanks for filing! This is a known issue that will take some time to address. In the meanwhile, I recommend initializing firebase-admin with a service account key. See https://firebase.google.com/docs/admin/setup#initialize_the_sdk
Initializing with service account key as mentioned above still giving me the same error.
manage to get it working differently in cmd and powershell
cmd
set GOOGLE_APPLICATION_CREDENTIALS=src/serviceAccountKey.json firebase functions:shell
firebase > getUsers.post(‘’).json({data:null});
Powershell
$Env:GOOGLE_APPLICATION_CREDENTIALS = “src/serviceAccountKey.json” firebase functions:shell
firebase > getUsers.post(‘’).json({data:null});
Notice that path is relative path to where you run the command.