Skip to content

With preferRest: true option set, I am unable to connect to auth emulator #2016

Open
@sushantdhiman

Description

@sushantdhiman

Describe your environment

  • Operating System version: Arch Linux
  • Firebase SDK version: 11.4.0
  • Firebase Product: auth, firestore, storage
  • Node.js version: 18.x
  • NPM version: 8.19.1

Additional related dependencies

Describe the problem

With preferRest: true option set, I am unable to connect to auth emulator

Steps to reproduce:

Here is my firebase initialization code

import { initializeApp, applicationDefault } from 'firebase-admin/app';
import { getAuth } from 'firebase-admin/auth';
import { initializeFirestore } from 'firebase-admin/firestore';

export const app = initializeApp({                                                                                                
  credential: applicationDefault(),
  projectId: process.env.GCLOUD_PROJECT,
});

export const auth = getAuth(app);
---export const firestore = initializeFirestore(app);
+++export const firestore = initializeFirestore(app, { preferRest: true });

When I run my application with preferRest: true, I get this error. It seems like emulators are not detected with this option.

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
  at GoogleAuth.getApplicationDefaultAsync (/home/node/app/node_modules/google-auth-library/build/src/auth/googleauth.js:209:19)
  at GoogleAuth.getClient (/home/node/app/node_modules/google-auth-library/build/src/auth/googleauth.js:635:17)
  at GrpcClient.createStub (/home/node/app/node_modules/google-gax/src/fallback.ts:280:27)
Caused by: Error: 
  at L0.getAll (/home/node/app/lib/server.js:113:509361)
  at ta.get (/home/node/app/lib/server.js:113:32416)
  at Function.findByIdentifier (/home/node/app/src/database/user.ts:115:44)\n

Application works correctly without preferRest option.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions