Next.js Discord

Discord Forum

Firebase Admin Private Key usage?

Answered
dperolio posted this in #help-forum
Open in Discord
Avatar
I'm going to pull my hair out. I'm using Next.js 14 and trying to put my Firebase private key in an .env file. I've also tried a .json file, but get the same issue. I get one of these 2 errors, depending on which method I try.
Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported
Failed to parse private key: Error: Invalid PEM formatted message.

I've tried adding \n's, removing \n's manually and with code, I've tried encoding the key to base64 and then decoding it, I've tried converting it to JSON and parsing it. I've tried downgrading my Node, I've tried upgrading my Node. Nothing works.

Please help.
Answered by dperolio
Downgrading to Node 18 seems to "fix" it. Although it's giving me a permissions error for some reason when it shouldn't be.
View full answer

17 Replies

Avatar
first, what happens if you paste the key just into your javascript as a js object?
and then consume it like that?
confirm it works
if you can confirm that works, then do a JSON.stringify(key)
Avatar
It works in my Astro project.
Avatar
and see if you can copy that into your env variables
Avatar
I can't confirm it works, in Next. I can't get it to work, in any shape.
If I paste it in directly, I get the Getting metadata from plugin failed with error: error:1E08010C:DECODER routines::unsupported error. The key is definitely a valid private key though. I've generated a new, fresh one and tried that as well, but same issue.
I don't even know if it's Node's, Next's, or Firebase's fault. :cryboi:
It was working fine a month ago in an Astro project though.
Avatar
are you using the firebase emulator by chance?
or the firebase cli?
one of the solutions i saw when googling this is your system time may be off
Avatar
No, not using the emulator.
Avatar
Downgrading to Node 18 seems to "fix" it. Although it's giving me a permissions error for some reason when it shouldn't be.
Answer
Avatar
In every case, it looks like it has to do with this @grpc-js thing.
Image