cert method
Returns a credential created from the provided service account that grants admin access to Firebase services. This credential can be used in the call to {@link firebase-admin.app#initializeApp}.
See {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK} for more details.
@example
// Providing a path to a service account key JSON file
const serviceAccount = require("path/to/serviceAccountKey.json");
initializeApp({
credential: cert(serviceAccount),
databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
@example
// Providing a service account object inline
initializeApp({
credential: cert({
projectId: "<PROJECT_ID>",
clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
}),
databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
@param serviceAccountPathOrObject - The path to a service account key JSON file or an object representing a service account key. @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent} to be used when retrieving access tokens from Google token servers.
@returns A credential authenticated via the provided service account that can be used to initialize an app.
Implementation
external Credential cert(JSAny serviceAccountPathOrObject, [Agent httpAgent]);