I am following Redwood’s Firebase authentication official guide but I am running into the following error.
Error: Exception in getAuthenticationContext: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
api |
api | 👉 Heads up
api |
api | The firebase app that the auth decoder is using wasn't initialized, which usually means that you have two different versions of firebase-admin.
api | Make sure that you only have one version of firebase-admin: `yarn why firebase-admin`
api |
api | at onContextBuilding (/home/garp/com.ganesshkumar/my-app/node_modules/@redwoodjs/graphql-server/dist/plugins/useRedwoodAuthContext.js:30:15)
api | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
api | at async Object.contextFactory (/home/garp/com.ganesshkumar/my-app/node_modules/@envelop/core/cjs/orchestrator.js:206:45)
api | at async processRequest (/home/garp/com.ganesshkumar/my-app/node_modules/graphql-yoga/cjs/process-request.js:46:26)
api | at async YogaServer.getResultForParams (/home/garp/com.ganesshkumar/my-app/node_modules/graphql-yoga/cjs/server.js:269:26)
api | at async handle (/home/garp/com.ganesshkumar/my-app/node_modules/graphql-yoga/cjs/server.js:324:25)
api | at async handlerFn (/home/garp/com.ganesshkumar/my-app/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:92:24)
api | at async execFn (/home/garp/com.ganesshkumar/my-app/node_modules/@redwoodjs/graphql-server/dist/functions/graphql.js:148:16)
api | at async requestHandler (/home/garp/com.ganesshkumar/my-app/node_modules/@redwoodjs/api-server/dist/bin.js:206:34)
and the getCurrentUser
function always returns null.
The header contains the correct Bearer token in Authorization header.
In the api workspace I see the following code
const adminApp = admin.initializeApp({
projectId: process.env.FIREBASE_PROJECT_ID
})
in api/src/lib/auth.ts file which means that this is getting initialized. What am I missing?