firebase / firebase/firebase-admin-node

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

Open
#2,016 11 comments 1 reaction 2 assignees Claimed by @MarkDuckworth View on GitHub
api: auth api: firestore
Dominant language
TypeScript
Stars
1.7k
Forks
419
Avg merge
3d 10h
Merged PRs (30d)
16

Description

### 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**
```
@google-cloud/logging@10.3.2
@google-cloud/pubsub@3.2.1
firebase-admin@11.4.0
```

### 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

```diff
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.