relief.melone
relief.melone

Reputation: 3312

angularfire2: The Cloud Firestore API is not enabled

I'm currently learning to implement angularfire2 in my project. Unfortunately I'm currently stuck. I set up my Angular-Project like described here

https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md

I also set up a database in firebase with a the rule set

{
  "rules": {
    ".read": "true",
    ".write": "true"
  }
}

But when I try to run the application in my console in the browser gives me the following error

ERROR Error: The Cloud Firestore API is not enabled for the project

Now I found a way to enable the API here

https://console.cloud.google.com/apis/library/firestore.googleapis.com/?project=projectname

leaving me now with the error

ERROR Error: Missing or insufficient permissions

My problem now is I can set up API keys (but also also got a different API-key from my firebase console?) and OAuths, but I have no idea how to implement those is my code. Just simply generating an API key and using that one in the environment.firebase config didn't work. Would be great if someone knew anything. I'll keep on trying and let you know if I get it to work as well.

Upvotes: 3

Views: 5694

Answers (3)

Sajith Mantharath
Sajith Mantharath

Reputation: 2607

To let others knows where it is in the firebase console:

Select your project then click on Database and change the dropdown from "Realtime Database" to "Cloud Firestore"

Upvotes: 7

forozco
forozco

Reputation: 21

I have had the same problem, and I have fixed it with this:

Go to:

https://console.firebase.google.com/u/1/project/**ProjectID**/database/firestore/rules

and change the rules to:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

Upvotes: 2

relief.melone
relief.melone

Reputation: 3312

Thanks to Edric i was able to solve it. He was right. My error was, that I was trying to use AngularFirestore and not AngularFireDatabase and AngularFireDatabaseModule. After i imported theese too it worked.

If you're having the same difficulties as I had, basically your module needs to look like described here

No provider for AngularFireDatabase, AngularFireAuth

Only thing, that I had to change, is you don't add AngularFireDatabase and AngularFireDatabaseModule to imports, but to providers. So in the end your module will look like this

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule, AngularFireDatabase } from 'angularfire2/database';
import { environment } from '../environments/environment';
import { AppComponent } from './app.component';


    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        AngularFireModule.initializeApp(environment.firebase),

      ],
      providers: [AngularFireDatabase, AngularFireDatabaseModule ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

Thanks again and I hope this will help others too, that struggle with setting up the FireDatabase

Upvotes: 1

Related Questions