firebase init firestore not work with existing project
DESCRIPTION
work very well with version 10.0.1
firebase login --no-localhost
**version 10.0.1 **
open https://accounts.google.com/o/oauth2....
** version 10.2.2 **
open https://auth.firebase.tools/login?code=....
[REQUIRED] Environment info
firebase-tools: 10.2.2
Platform: ubuntu 20
[REQUIRED] Test case

[REQUIRED] Steps to reproduce
firebase login --no-localhost
firebase init firestore
[REQUIRED] Expected behavior
create firebase.rules file
[REQUIRED] Actual behavior
Error: It looks like you haven't used Cloud Firestore in this project before. Go to https://console.firebase.google.com/project/<PROJECT-ID>/firestore to create your Cloud Firestore database.
Have you enabled Cloud Firestore on your existing project before you tried this? If so, this is definitely a bug or a permission issue (and please let us know if you're using a non-Admin account or service account). If not, please follow the link which explains about setting up Firestore.
Yes, I created my firestore database one month ago.
To confirm the type of issue, can you run the command with --debug and provide the last bit of output? It's likely there's an HTTP request that's returning some type of error or a check that's being made that's incorrect. Thanks!
@bkendall
[2022-03-08T19:10:53.980Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2022-03-08T19:10:53.980Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
<request body omitted>
[2022-03-08T19:10:54.537Z] <<< HTTP RESPONSE 400 {"cache-control":"no-cache, no-store, max-age=0, must-revalidate","date":"Tue, 08 Mar 2022 19:10:54 GMT","expires":"Mon, 01 Jan 1990 00:00:00 GMT","pragma":"no-cache","content-type":"application/json; charset=utf-8","vary":"X-Origin, Referer, Origin,Accept-Encoding","server":"scaffolding on HTTPServer2","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2022-03-08T19:10:54.539Z] >>> HTTP REQUEST GET https://appengine.googleapis.com/v1/apps/eventos-staging-93d3a
[2022-03-08T19:10:55.280Z] <<< HTTP RESPONSE 401 {"www-authenticate":"Bearer realm=\"https://accounts.google.com/\", error=\"invalid_token\"","vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Tue, 08 Mar 2022 19:10:55 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"}
[2022-03-08T19:10:55.281Z] <<< HTTP RESPONSE BODY {"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}}
[2022-03-08T19:10:55.282Z] error getting database typeHTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. {"name":"FirebaseError","children":[],"context":{"body":{"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}},"response":{"statusCode":401,"body":{"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}},"headers":{"www-authenticate":"Bearer realm=\"https://accounts.google.com/\", error=\"invalid_token\"","vary":"X-Origin, Referer, Origin,Accept-Encoding","content-type":"application/json; charset=UTF-8","date":"Tue, 08 Mar 2022 19:10:55 GMT","server":"ESF","cache-control":"private","x-xss-protection":"0","x-frame-options":"SAMEORIGIN","x-content-type-options":"nosniff","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"","accept-ranges":"none","transfer-encoding":"chunked"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"appengine.googleapis.com","port":443,"hostname":"appengine.googleapis.com","hash":null,"search":null,"query":null,"pathname":"/v1/apps/eventos-staging-93d3a","path":"/v1/apps/eventos-staging-93d3a","href":"https://appengine.googleapis.com/v1/apps/eventos-staging-93d3a"},"method":"GET"}}},"exit":1,"message":"HTTP Error: 401, Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":401}
[2022-03-08T19:10:55.290Z] database_type: undefined
Error: It looks like you haven't used Cloud Firestore in this project before. Go to https://console.firebase.google.com/project/eventos-staging-93d3a/firestore to create your Cloud Firestore database.
This seem to be a degration occurred from v10.2.0, from which some OAuth scopes are missing compared to login without --no-localhost option.
I just had the same error, with the exact same context. I have the issue with 10.4.2. Reverted to 10.1.5, it didn't work, so I logged out, logged in again and there it worked.
I also did login firebase with option --no-localhost via firebase-cli v10.5.0.
In my case, it did not work when I logged out and in again.
@PorcoRosso85 until this gets fixed I guess that you will have to go down to 10.1.5.
hello, I'm in bandwagon when it comes to this problem: [firebase init firestore not work with existing project] I'm using firebase CLI version 10.6.0
but somehow I manage to deal with it, here's my solution/timeline:
- I install using firebase login --no-localhost because encounter problems with firebase login
- encountered with errors: cannot install firestore but hosting part can.
- try to reset database, created again but still get error: cannot install firestore
- then I logout, then login using ONLY firebase login, not the firebase login --no-localhost
- bang! solved!
hope it helps~
We had to make an adjustment to the --no-localhost flow in the past week which should have addressed this issue. If you could give --no-localhost a try again, that'd be great. If there's more issues, please comment or open a new issue.
I have this issue using latest firebase-tools as of today, --no-localhost doesn't help.
new local firebase project trying to connect to a new (an hour or so old) firebase project with Blaze billing enabled, web project created and firestore created/enabled.
debug logs:
[2022-11-08T23:06:27.479Z] <<< [apiv2][body] GET https://appengine.googleapis.com/v1/apps/XXXXX {"error":{"code":404,"message":"App does not exist.","status":"NOT_FOUND"}}
[2022-11-08T23:06:27.481Z] error getting database typeHTTP Error: 404, App does not exist. {"name":"FirebaseError","children":[],"context":{"body":{"error":{"code":404,"message":"App does not exist.","status":"NOT_FOUND"}},"response":{"statusCode":404}},"exit":1,"message":"HTTP Error: 404, App does not exist.","status":404}
[2022-11-08T23:06:27.483Z] database_type: undefined
(project id redacted)
I am also having this problem with version 11.16.0. I just made my project, initialized firestore database, and tried "firebase init"
Logging in with --no-localhost flag did not help
=== Firestore Setup
[2022-11-10T01:34:59.523Z] >>> [apiv2][query] GET https://serviceusage.googleapis.com/v1/projects/XXX/services/firestore.googleapis.com [none]
[2022-11-10T01:34:59.524Z] >>> [apiv2][(partial)header] GET https://serviceusage.googleapis.com/v1/projects/XXX/services/firestore.googleapis.com x-goog-quota-user=projects/XXX
[2022-11-10T01:34:59.841Z] <<< [apiv2][status] GET https://serviceusage.googleapis.com/v1/projects/XXX/services/firestore.googleapis.com 200
[2022-11-10T01:34:59.841Z] <<< [apiv2][body] GET https://serviceusage.googleapis.com/v1/projects/XXX/services/firestore.googleapis.com [omitted]
[2022-11-10T01:34:59.841Z] >>> [apiv2][query] GET https://appengine.googleapis.com/v1/apps/XXX [none]
[2022-11-10T01:35:00.243Z] <<< [apiv2][status] GET https://appengine.googleapis.com/v1/apps/XXX 404
[2022-11-10T01:35:00.243Z] <<< [apiv2][body] GET https://appengine.googleapis.com/v1/apps/XXX {"error":{"code":404,"message":"App does not exist.","status":"NOT_FOUND"}}
[2022-11-10T01:35:00.244Z] error getting database typeHTTP Error: 404, App does not exist. {"name":"FirebaseError","children":[],"context":{"body":{"error":{"code":404,"message":"App does not exist.","status":"NOT_FOUND"}},"response":{"statusCode":404}},"exit":1,"message":"HTTP Error: 404, App does not exist.","status":404}
[2022-11-10T01:35:00.244Z] database_type: undefined
Error: It looks like you haven't used Cloud Firestore in this project before. Go to https://console.firebase.google.com/project/XXX/firestore to create your Cloud Firestore database.
I am having the same issue as well.
I waited ~12h to see if it was just some propagation issue but not joy. Luckily I was able to delete the "existing" project and recreate it via the firebase cli.
Also experiencing this issue
Recreating the project via the firebase cli didn't work unfortunately, still running into the same issue:
Error: It looks like you haven't used Cloud Firestore in this project before
Firestore setup/populated and Blaze billing enabled on everything
Yep same issue. If I click the link it takes me to my database (which does exist, thank you very much.) If I use --debug, I get a 404 thing:
[2022-11-10T16:48:25.510Z] error getting database typeHTTP Error: 404, App does not exist. {"name":"FirebaseError","children":[],"context":{"body":{"error":{"code":404,"message":"App does not exist.","status":"NOT_FOUND"}},"response":{"statusCode":404}},"exit":1,"message":"HTTP Error: 404, App does not exist.","status":404}
For me this was resolved by setting the "Default GCP resource location" under Project settings (which it forced me to set to the location of the Firestore database)
For me this was resolved by setting the "Default GCP resource location" under Project settings (which it forced me to set to the location of the Firestore database)
THIS WORKED!!
For me this was resolved by setting the "Default GCP resource location" under Project settings (which it forced me to set to the location of the Firestore database)
What exactly is this, and where?
Cheers
@goofballLogic this worked for me, too! Silly this value is not automatically filled out (it only has one option?!)