Stitch cannot parse private key

I’m trying to initializeApp with firebase-admin and I’ve uploaded the dependencies.

I’m creating a trigger function so I can generate a JWT token, to be sent to firebase for authentication.

The same code below works for my backend server, but when I try to use it in Stitch function, it returns “Error: Failed to parse private key: Error: Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.” as error.

var admin = require('firebase-admin')
        try {
            admin.initializeApp({credential: admin.credential.cert({
                "project_id": "someproject-id",
                "private_key": "-----BEGIN PRIVATE KEY-----\nKEY\n-----END PRIVATE KEY-----\n",
                "client_email": "",
            } catch(err) {
        //var token = await admin.auth().createCustomToken(uid)
        console.log('token', token)  


Hi Dave – Looks like this may be a place where we want to extend how our dependency resolution works. Would you mind sharing the version of ‘firebase-admin’ that you’re using so we can try to reproduce?


I am having the same exact problem with firebase-admin 8.12.1

Please help.

Same here 8.13.0

latest version. you mean you guys actually got it working before?


i am getting the same problem “can not parse private key” for firebase-admin v8.9.2.

have you got it working?

1 Like

Can someone on the Mongodb Realm team give us a timeline for fixing this?

Its been almost a year since this issue was created.

How are we supposed to get confidence and migrate our project to mongodb-realm if something as basic as sending a firebase notification using a function is not possible.


1 Like

We are also facing the same problem while migrating our project, how long will it take to fix it?