gladly-team / next-firebase-auth

Simple Firebase authentication for all Next.js rendering strategies
https://nfa-example-git-v1x-gladly-team.vercel.app/
MIT License
1.34k stars 290 forks source link

Service account object must contain a string \"private_key\" property."} #498

Closed 6174 closed 2 years ago

6174 commented 2 years ago

Describe the bug New to next.js & firebase, my code is the same with example, but stuck on this issue, I find the same issue in the issue list, but no solution. image

the code

firebaseAdminInitConfig: {
      credential: {
        privateKey: process.env.FIREBASE_PRIVATE_KEY
          ? JSON.parse(process.env.FIREBASE_PRIVATE_KEY)
          : undefined,
      },
    },

Versions

next-firebase-auth version: Firebase JS SDK: ^9.9.0 Next.js: 12.2.2

Additional context I log out the private key with JSON.parse

pk {
  type: 'service_account',
  project_id: 'xxxx',
  private_key_id: 'xxxx',
  private_key: '-----BEGIN PRIVATE KEY-----\n' +
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +
    'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +