I'm using firebase functions and I want to initializeApp with service account key json into credential and I get the error
Argument of type '{ "type": string; "project_id": string; "private_key_id": string; "private_key": string; "client_...' is not assignable to parameter of type 'string | ServiceAccount'. Type '{ "type": string; "project_id": string; "private_key_id": string; "private_key": string; "client_...' has no properties in common with type 'ServiceAccount'.
my index.ts file
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
import {serviceAccount} from './serviceAccount'
console.log(functions.config())
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL:functions.config().firebase
});
export const firestore = admin.firestore();
export const firebase = admin.database();
serviceAccount.ts
export const serviceAccount = {
"type": "service_account",
"project_id": "lxxxxxx",
"private_key_id": "xxxxxx",
"private_key": "-----BEGIN PRIVATE KEY-----xxxxxxx---END PRIVATE KEY-----\n",
"client_email": "firebase-axxxxx-9b58b.iaxxxceaccount.com",
"client_id": "xxxxx",
"auth_uri": "https://accounts.google.com/o/xxxxx",
"token_uri": "https://accounts.google.com/o/oxxxxn",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"clixxxxxx": "https://www.googleapis.com/robot/v1/metadataxxxxirebase-adminsdk-uxxxxxxrviceaccount.com"
}
the error in this line of code
credential: admin.credential.cert(serviceAccount),