With Firebase Admin not able to create user in local emulator
See original GitHub issueTeam
I’m trying to create user with my Node JS backend with the following code
const admin = require("firebase-admin");
process.env.FIRESTORE_EMULATOR_HOST = "localhost:8080";
process.env['FIRESTORE_EMULATOR_HOST'] = 'localhost:8080';
var serviceAccount = require("../service-account.json");
admin.initializeApp({
projectId:"tndfc-app"
});
let data = {
email: "santhoshlfms@gmail.com", password: "12345678"
}
try {
admin.firestore().settings({
host:"localhost:33007",
ssl:false
})
const user = await admin.auth().createUser({ email: data.email, password: data.password, emailVerified: false, displayName: 'John Doe', disabled: false });
} catch (err) {
console.log(err)
}
I tried to read similar git issues threads, but I’m not able to connect to emulator and create user , is this actually supported in firebase emulator right now ? version used : “firebase”: “^9.1.2”, “firebase-admin”: “^9.12.0”
Credential implementation provided to initializeApp() via the "credential" property fail initializeApp() ved to fetch a valid Google OAuth2 access token withd Google OAuth2 ac the following error: "Error fetching access token:g access token: Er Error while making request: getaddrinfo ENOTFOUND adata.google.inter
metadata.google.internal. Error code: ENOTFOUND
Ques: How do I connect to local emulator for Auth via Admin SDK, Im trying to create default users via admin-sdk and access then / authenticate then in UI using firebase/auth [signInWithEmailAndPassword] method.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Connect your app to the Authentication Emulator - Firebase
Create, update and manage emulated user accounts for testing ... The Firebase Local Emulator Suite emulates products for a single Firebase project.
Read more >Create user with firebase admin sdk that can signIn using ...
@Mani I agree the method is there. However, the user won't be created in the Emulator, but in the actual Firebase project. Can...
Read more >firebase-admin - npm
Firebase admin SDK for Node.js. Latest version: 11.4.1, last published: 4 days ago. Start using firebase-admin in your project by running ...
Read more >Running firebase admin and storage emulator locally without ...
I had a similar issue and remember it being around passing or not passing those parameters to initializeApp while in emulation.
Read more >Using Firebase Authentication - FlutterFire
idTokenChanges() , userChanges() & authStateChanges() will also not fire if you disable or delete the User via your own firebase admin sdk implementation...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That error implies the SDK is still operating in the non-emulator mode. If the emulator mode was correctly enabled, the implementation will skip the credential lookup entirely:
https://github.com/firebase/firebase-admin-node/blob/b26501b023194b664df5d81f526e237f975fae71/src/auth/auth-api-request.ts#L231-L237
I’d start by checking your env variables. You have mentioned
FIRESTORE_EMULATOR_HOST
. The correct variable for Auth isFIREBASE_AUTH_EMULATOR_HOST
.@hiranya911 : Thanks ! FIREBASE_AUTH_EMULATOR_HOST helped to resolved