-
Notifications
You must be signed in to change notification settings - Fork 950
Open
Labels
Description
[REQUIRED] Describe your environment
- Operating System version: Windows 10
- Browser version: _____
- Firebase SDK version: 9.13.0
- Firebase Product: auth
[REQUIRED] Describe the problem
When using the auth emulator, apikey probably should not be necessary, but an auth/invalid-api-key
error will occur if it is not set.
FirebaseError: Firebase: Error (auth/invalid-api-key).
7 | });
8 | export const firestore = getFirestore(app);
> 9 | export const auth = getAuth(app);
| ^
10 |
11 | connectFirestoreEmulator(firestore, 'localhost', 8080);
12 | connectAuthEmulator(auth, 'http://localhost:8081');
at createErrorInternal (node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/core/util/assert.ts:142:44)
at _assert (node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/core/util/assert.ts:167:30)
at node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/core/auth/register.ts:68:11
at Component.instanceFactory (node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/core/auth/register.ts:95:10)
at Provider.Object.<anonymous>.Provider.getOrInitializeService (node_modules/.pnpm/@[email protected]/node_modules/@firebase/component/src/provider.ts:318:33)
at Provider.Object.<anonymous>.Provider.initialize (node_modules/.pnpm/@[email protected]/node_modules/@firebase/component/src/provider.ts:242:27)
at initializeAuth (node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/core/auth/initialize.ts:66:25)
at getAuth (node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@firebase/auth/src/platform_node/index.ts:50:16)
at Object.<anonymous> (test/firebase.ts:9:28)
When I put a random value in apiKey
it seems to work fine.
export const app = initializeApp({
projectId: 'test',
apiKey: 'test'
});
The check for apiKey
is done on the client side, which was appended before the auth emulator was created, so it is probably not needed.
https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/core/auth/register.ts#L68-L71
Steps to reproduce:
Initialize auth without specifying apiKey in initializeApp
Relevant Code:
import { connectAuthEmulator, getAuth } from 'firebase/auth';
import { initializeApp } from 'firebase/app';
export const app = initializeApp({
projectId: 'test',
});
export const auth = getAuth(app); // <- error here
connectAuthEmulator(auth, 'http://localhost:8081');
simenness, DannyAlas, anjan8016, OtabekVaxobov, jesslyoung and 3 more