Ubuntu Gnome 16.044.4.0auth()This morning I have update the firebase version of my webapp from 4.3.0 to 4.4.0. And this update make my registering method not working.
The following error is caught, and I received this error code : auth/invalid-api-key
But I am pretty sure than the API key is correct, because the login method work, and the only modification I do is to update the Firebase API.
My registering method :
/**
* Method for create a new user with an email an a password
* @param user object containing data about the new user
* @param _success callback if success
* @param _error callback if an error occurred
*/
AuthenticationDriver.register = function (user, _success, _error) {
//call the firebase method
firebase.auth().createUserWithEmailAndPassword(user.email, user.$$password)
.then(function () {
//in case of succes: read new values
user.uid = firebase.auth().currentUser.uid;
user.registeredOn = firebase.database.ServerValue.TIMESTAMP;
user.save(function() {
user.remember();
});
_success();
}).catch(function(error) {
console.error(error);
_error(error.message);
});
};
I just think there is an issue in the last update of the Firebase API. Because when I switch back to 4.3.0 the issue disappear.
Can you check your network console? Is there any error being thrown?
I am unable to recreate it and I would be surprised the version change caused this.
Here is my console when I execute my App with v4.4.0

I execute the signup method just after the User Signed Out! message.
Ps: I have forgot to precise than the account is still created in my database.
Here is my console when I execute my App with v4.3.0

Same as later, I execute the signup method just after the User Signed Out! message.
The API key is being substituted for 'undefined' explicit string. Must be something in your code when initializing it. Try checking how initializeApp is called. It could shed some light on this.
Inspect: firebase.app().options
Does it contain the API key?
Yes I initialise firebase like this :
// Initialize Firebase configuration
var config = {
dev: {
apiKey: "AIzaSyDccccccctndu5uxxxxxxx6OlFzBEd-3uQ",
authDomain: "dev.firebaseapp.com",
databaseURL: "https://dev.firebaseio.com",
projectId: "dev",
storageBucket: "dev.appspot.com",
messagingSenderId: "10000000000065"
},
prod: {
//TODO: Add prod database
}
};
// Initialize Firebase connection
firebase.initializeApp(config[runningMode]);
I ask again:
Inspect: firebase.app().options
Does it contain the API key?
And I log firebase.app().options in the console were I call firebase.auth().createUserWithEmailAndPassword and the result is here:
{
apiKey: "AIzaSyDccccccctndu5uxxxxxxx6OlFzBEd-3uQ",
authDomain: "dev.firebaseapp.com",
databaseURL: "https://dev.firebaseio.com",
messagingSenderId: "10000000000065",
projectId: "dev",
storageBucket: "dev.appspot.com"
}
Sorry for multiples edits, I'm a little in stress right now, and I do mistakes.
Hmm, this is quite strange. Are you obfuscating your code or parts of it?
I speculate it is related to that.
There were other similar issues reported in the past:
https://github.com/firebase/firebase-js-sdk/issues/154
https://github.com/firebase/firebase-js-sdk/issues/121
The Auth team has not changed anything in how the API key is picked up from firebase app. We simply get it from app.options.apiKey. It seems like app.options is evaluating to 'undefined'.
One possible reason is that you are obfuscating your config initialization code, firebase-app.js and firebase-auth.js differently.
Though that doesn't explain why it worked before.
I think this must be unique to your environment as this is the first and only report I have received on all channels regarding this. A lot of noise would have been generated for everyone who upgraded to the latest version as the API key is used for everything.
Ok thank, I'll try to amend my issue later.
Same issue here, updated now getting this error. @lucasmaurice what turned out to be the problem?
I have the same problem. Did you guys find the root cause? @lucasmaurice @Kamshak
@nexost
Uh close to a year ago now, if I recall correctly it was an issue with something webpack related for me (so the api key ended up being wrong). I think to debug it I went into chrome dev tools, looked at the compiled bundle and put a breakpoint onto the place where it calls initializeApp. At that point you can verify that all the data is correct.
I have the solution finally, just check how you have imported your firebaseConfig.js where you have initilize your firebase.
most of the case we export default firebaseConfig and import it as a object
import {firebaseConfig} from './src/config/FirebaseConfig'; ===== Wrong Order
import FirebaseConfig from './src/config/FirebaseConfig'; ===== Correct Order