app.auth(...).signInWithCredential is not a function firebase error

  • Thread starter Louisa Scheinost
  • Start date

Louisa Scheinost

I'm trying to add google login to my node js firebase app. I'm getting the following error: app.auth(...).signInWithCredential is not a function

Here's the code on the server

var credential = firebase.auth.GoogleAuthProvider.credential(id_token);
return app.auth().signInWithCredential(credential);

On the client

// We need to register an Observer on Firebase Auth to make sure auth is initialized.
var unsubscribe = app.auth().onAuthStateChanged((firebaseUser) => {
// Check if we are already signed-in Firebase with the correct user.
// Build Firebase credential with the Google ID token.
var credential = firebase.auth.GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
// Sign in with credential from the Google user.
firebase.auth().signInWithCredential(credential).catch( (error) => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email =;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
}).then( (success) => {

var id_token = googleUser.getAuthResponse().id_token;'/auth/google-login', {
id_token: id_token
}).then(response => {
var result =;
if (result.status === "ok") {
this.setState({complete: true});
} else if (result.error) {
this.setState({error: result.error});
}).catch(error => {
this.setState({error: "error"});

What I'm I doing wrong?

At the top of the nodejs file, I have

var app = require('./base');

where base :

var serviceAccount = require("./service-account-file.json");

const app = fadmin.initializeApp({
credential: fadmin.credential.cert(serviceAccount),
databaseURL: ""
module.exports = app;

Continue reading...