5

I have a firebase cloud function, which gets the data from the cloud firestore.

const userSnapshot = await admin.firestore().collection('users').doc(user).get()

when this api is deployed locally using firebase emulators:start.

I get the following error:

The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.
⚠  Google API requested!
   - URL: "https://oauth2.googleapis.com/token"
   - Be careful, this may be a production service.
>  Auth error:Error: invalid_grant

This is happening only after updating the firebase-tools. Previously it was working fine using firebase serve --only function --port=9000. In this tools version I am not able to set the port through command line.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Indhu
  • 9,806
  • 3
  • 18
  • 17
  • Please post your issue on the Firebase emulator GitHub. https://github.com/firebase/firebase-tools – Doug Stevenson May 09 '19 at 16:27
  • Hi! Can you ensure you're running `firebase-tools@6.9.1`, this was a known issue in `6.9.0` – Abe Haskins May 09 '19 at 16:59
  • It is in 6.9.1 version but still the error exists – Indhu May 10 '19 at 04:14
  • In a bug they had asked to delete application_default_credential.json from ~/.config/gcloud. After, I got this error:The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error. ⚠ Google API requested! - URL: "https://oauth2.googleapis.com/token" - Be careful, this may be a production service. > Error: 16 UNAUTHENTICATED: 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. – Indhu May 10 '19 at 04:18

1 Answers1

1

This is resolved in 6.9.2

We can use firebase serve with port number to access firestore.

https://github.com/firebase/firebase-tools/issues/1265

Indhu
  • 9,806
  • 3
  • 18
  • 17