Trouble Reading the database when authenticated as User (Ionic/Angular/FireBase app)

157 views
Skip to first unread message

David Skillman

unread,
Jul 26, 2017, 7:28:41 PM7/26/17
to Firebase Google Group
Hi there,

Loving FireBase so far, I'm using it for an app I'm creating.

I just recently encountered an issue where I receive the following error in the browser console:

"FIREBASE WARNING: Provided authentication credentials for the app named "[DEFAULT]" are invalid. This usually indicates your app was not initialized correctly. Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/. "

This only happens when I login to my app as a registered user (using Email/Password), and I can't see the data.
If I am not signed in, I do not get the above error and the data on FireBase can be displayed, edited, and deleted. As such I do not think my apiKey or databaseURL are incorrectly initiaized.

My environment:
Ionic Framework: 3.5.3
Ionic App Scripts: 2.0.2
Angular Core: 4.1.3
Angular Compiler CLI: 4.1.3
Node: 6.11.0
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Firefox/54.0

Any ideas? I tried following this thread but I'm not sure it's the same issue; I am not setting up a node server.

Kind regards,
David

Kato Richardson

unread,
Jul 26, 2017, 8:05:27 PM7/26/17
to Firebase Google Group
In one of those instances, you must be trying to access database() or auth() before you call initializeApp(). You probably just need to move initializeApp() into your initialization code so that it occurs before your auth methods are accessed.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/8bbfdcf7-4b44-42b3-af52-6689ed00484d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

David Skillman

unread,
Jul 27, 2017, 3:38:02 PM7/27/17
to Firebase Google Group
Hi Kato, thanks for your reply.

I have set it up in the app.module.ts as per step 5 here: https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md
@NgModule({
declarations: [
MyApp,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(environment.firebase),
AngularFireDatabaseModule,
AngularFireAuthModule,
.
.

Could it be because I am trying to use AngularFireAuth in my app.component.ts? I am determining the rootpage base on whether the user is signed in or not:
const unsubscribe = afAuth.auth.onAuthStateChanged(user => {
if(!user) {
this.rootPage = 'welcome';
unsubscribe();
} else {
this.rootPage = 'uni-pal';
unsubscribe();
}
});

If I try to move my initializeApp somehwere else I get a runtime error: No provider for InjectionToken FirebaseAppConfigToken.

Thanks,
David


On Thursday, July 27, 2017 at 1:05:27 AM UTC+1, Kato Richardson wrote:
In one of those instances, you must be trying to access database() or auth() before you call initializeApp(). You probably just need to move initializeApp() into your initialization code so that it occurs before your auth methods are accessed.

David Skillman

unread,
Aug 2, 2017, 2:44:24 PM8/2/17
to Firebase Google Group
In case anybody comes across this with the same issue, it appears that this is an issue with Firebase 4.1.4 and until this is fixed you should downgrade to firease 4.1.3.

In your package.json if you have a greater version than 4.1.3 or something like ^4.1.3, simply replace it with 4.1.3 without the caret (^) symbol. Then run npm install.

Issue report:
https://status.firebase.google.com/incident/Realtime%20Database/17068
"There is a known issue with authenticating to the Database in v4.1.4 of the JS SDK. Please remain on v4.1.3 until this issue is fixed."

Solution found here:
https://groups.google.com/forum/#!topic/firebase-talk/0i1rCecwz4I
Reply all
Reply to author
Forward
0 new messages