Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase functions - admin.firestore() get() throws auth error on local serving

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.

like image 655
Indhu Avatar asked Nov 07 '22 17:11

Indhu


1 Answers

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

like image 86
Indhu Avatar answered Nov 15 '22 08:11

Indhu