Firebase Auth Fails (Firebase app didn't created)[SOLVED]

[SOLUTION] * I generated a firebase initializer and pasted this below,

export function initialize(application) {
  var config = {
    apiKey: "*replace with yours",
    authDomain: "*replace with yours",
    databaseURL: *"replace with yours,
    storageBucket: "*replace with yours",
    messagingSenderId: "*replace with yours"
 };
 firebase.initializeApp(config);
}

export default {
  name: 'firebase',
  initialize
};

Hi everyone.I was trying to implement natural firebase authentication(email/password).

When i hit login/logout/singup i get this error

Uncaught Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp().(…)

I know for a fact that my app is connected to my firebase project.I tested to see if it is creating records.I generated simple model and a route to display them.They work.But when i hit login logout or singuo i get the error

 -----------------app/templates/index.hbs-------------------
E{{input value=email}}
P{{input value=password}}
<button {{action 'login'}}>Login</button>
<button {{action 'signup'}}>Signup</button>
<button {{action 'logout'}}>Logout</button>
 ------------app/routes/index.js------------
    login(){
  firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
    var errorCode = error.code;
    var errorMessage = error.message;
  });
},
signup(){
  firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {

    var errorCode = error.code;
    var errorMessage = error.message;
  });
},
logout(){
  firebase.auth().signOut().then(function() {
}, function(error) {
});
    }

I enabled email/password auth option

Why don’t you ask the person who wrote the firebase auth API? I doubt anyone here can help you, it’s not Ember-specific.

1 Like

If you are using emberfire, you should follow their guide for authentication, which suggests using torii and creating a firebase adapter. But if for some reason you don’t want to rely on that, you should try using the firebaseapp service:

firebaseApp: Ember.inject.service(),
signup: {
  this.get('firebaseApp').auth() ...
}

(I haven’t fully tried this, but it should work: https://github.com/firebase/emberfire/blob/353ad6b9e53a90bc92b073391b086ff42a0569d6/addon/torii-adapters/firebase.js#L51)

If you are NOT using emberfire, you’ll either need to import the firebase library as a global (The Ember CLI - Introduction - Ember CLI Guides), or if it’s a named asset (The Ember CLI - Introduction - Ember CLI Guides) maybe you need to add the import in your index route: import * as firebase from "firebase"; and probably manually initialize the app in some way too.

Sorry if these are just pointers, i hope it helps

1 Like

Thanks for answering.I have actually tried few different authentication tutorials including this one.Still giving out same error.

I will try tı connect a guy from firebase for this issue.No matter what i try, with torii/without torii, injecting firebase, firebaseApp, it always says

    Uncaught Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp().(…)

I don’t think it is ember related anymore.Because i don’t have any problems with CRUD or deployment.

I will leave a feedback if it gets solved.

Any updates on authentication and firebase? :slight_smile:

@Harun_Tuncay Did u find the solution