question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore emulator auth connection issues

See original GitHub issue

Environment details

  • OS: macOS 10.14.2
  • Node.js version: 8.15.0
  • yarn version: 1.12.3
  • @google-cloud/firestore version: 0.19.0
  • firestore emulator version: 1.2.2

Description

Hey there! 👋

I’m trying to connect to local firestore emulator for testing, but it seems to have auth issues. I’ve checked @firebase/testing package for a reference, and the only clue I have is token hjacking which I can’t achieve in any possible way I’ve tried with this module.

It there maybe a way to override access token to owner or a way to add custom auth headers I’m missing? Thanks.

Steps to reproduce

  1. Run the emulator:
java -Duser.language=en -jar ~/.cache/firebase/emulators/cloud-firestore-emulator-v1.2.2.jar --port 8080 --rules firestore.rules
// firestore.rules
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}
  1. Connect to it:
const grpc = require('grpc');

const firestore = new Firestore({
  projectId: 'test-lzqnvo3eh', // project id is random for each run
  timestampsInSnapshots: true,
  sslCreds: grpc.credentials.createInsecure(),
  servicePath: 'localhost',
  port: 8080,
  'grpc.initial_reconnect_backoff_ms': 100,
  'grpc.max_reconnect_backoff_ms': 100,
});
  1. Run sample operation:
await firestore.doc('foo/bar').set({ value: 42 });

Logs

  • firestore client logs:
Firestore (0.19.0) 2019-01-04T14:49:41.334Z ##### [Firestore]: Initialized Firestore
Firestore (0.19.0) 2019-01-04T14:49:42.490Z eyadC [WriteBatch.commit]: Sending 1 writes
Firestore (0.19.0) 2019-01-04T14:49:42.547Z ##### [Firestore]: Initialized Firestore GAPIC Client
Firestore (0.19.0) 2019-01-04T14:49:42.550Z eyadC [Firestore.request]: Sending request: {"database":"projects/test-lzqnvo3eh/databases/(default)","writes":[{"update":{"name":"projects/test-lzqnvo3eh/databases/(default)/documents/foo/bar","fields":{"value":{"integerValue":42}}}}]}
Firestore (0.19.0) 2019-01-04T14:49:43.467Z eyadC [Firestore.request]: Received error: { Error: 7 PERMISSION_DENIED: false for 'create' @ L4, false for 'update' @ L4 }
Firestore (0.19.0) 2019-01-04T14:49:43.467Z eyadC [Firestore._retry]: Request failed with unrecoverable error
  • firestore emulator output:
API endpoint: http://[::1]:8080
API endpoint: http://127.0.0.1:8080
Dev App Server is now running.

Jan 04, 2019 3:28:37 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
INFO: Adding handler(s) to newly registered Channel.
Jan 04, 2019 3:28:37 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ryanpbrewstercommented, Feb 5, 2019

Glad to hear it. There are a few additional features we’ve recently added that I’m hoping prove helpful, and tighter integration with Cloud Functions in the pipeline. Stay tuned 😃

1reaction
sbekrincommented, Feb 3, 2019

Quick update: firestore-emulator v1.3.0 seems to be working as expected (except datastore methods like .listDocuments()) and looks more or less suitable for testing 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect your app to the Authentication Emulator - Firebase
For security reasons, the Authentication emulator issues unsigned ID tokens, which are only accepted by other Firebase emulators, or the Firebase Admin SDK ......
Read more >
[firebase auth] Cannot connect to emulator with hostname ...
The app can connect without issues to the firestore emulator but fails to connect to the firestore auth emulator.
Read more >
A network error (such as timeout, interrupted connection or ...
The error only comes up when I try to connect to the emulator, and internet connection is horrible where I am. I additionally...
Read more >
Firestore emulator problem : r/Firebase - Reddit
I tried with the auth emulator and everything went smoothly, but Firestore is giving me some problems. This is my main function:
Read more >
Connect Your Application to the Emulator Suite
Realtime Database. connectDatabaseEmulator. 9000 ; Cloud Firestore. connectFirestoreEmulator. 8080 ; Cloud Storage. connectStorageEmulator. 9199 ; Cloud Functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found