The following error appears when you start the Admin SDK:
UnhandledPromiseRejectionWarning: Error: Failed to parse private key: Error: Too few bytes to read ASN.1 value
This is my code used to start the Admin SDK:
admin.initializeApp({
credential: admin.credential.cert({
projectId: 'Extracted from the firebase console',
clientEmail: 'Project settings -> Service Account -> Firebase service account',
privateKey: '-----BEGIN PRIVATE KEY-----\n<KEY>\n-----END PRIVATE KEY-----\n'
}),
KEY = Retrieved from the text of the private key file.Generated in Console
I also tried using the console snippet and gave this error:
SyntaxError: /data/data/com.termux/files/home/textos-da-ju/scripts/gerarPDF/serviceAccountKey.json: Unexpected token e in JSON at position 0
Does anyone know how to start this admin SDK correctly? Node version: 11.14.0
Projet settings => account of service. At the bottom of the page, you can find out each admin sdk for different programming language. – DataHearth May 25 '19 at 20:24