credential namespace

Signature:

export declare namespace credential 

Variables

Variable Description
applicationDefault Returns a credential created from the Google Application Default Credentials that grants admin access to Firebase services. This credential can be used in the call to initializeApp().Google Application Default Credentials are available on any Google infrastructure, such as Google App Engine and Google Compute Engine.See Initialize the SDK for more details.
cert 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 initializeApp().See Initialize the SDK for more details.
refreshToken Returns a credential created from the provided refresh token that grants admin access to Firebase services. This credential can be used in the call to initializeApp().See Initialize the SDK for more details.

Type Aliases

Type Alias Description
Credential Interface that provides Google OAuth2 access tokens used to authenticate with Firebase services.In most cases, you will not need to implement this yourself and can instead use the default implementations provided by the admin.credential namespace.

credential.applicationDefault

Returns a credential created from the Google Application Default Credentials that grants admin access to Firebase services. This credential can be used in the call to initializeApp().

Google Application Default Credentials are available on any Google infrastructure, such as Google App Engine and Google Compute Engine.

See Initialize the SDK for more details.

Signature:

applicationDefault: typeof applicationDefaultFn

Example

admin.initializeApp({
  credential: admin.credential.applicationDefault(),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});

credential.cert

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 initializeApp().

See Initialize the SDK for more details.

Signature:

cert: typeof certFn

Example 1

// Providing a path to a service account key JSON file
var serviceAccount = require("path/to/serviceAccountKey.json");
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});

Example 2

// Providing a service account object inline
admin.initializeApp({
  credential: admin.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"
});

credential.refreshToken

Returns a credential created from the provided refresh token that grants admin access to Firebase services. This credential can be used in the call to initializeApp().

See Initialize the SDK for more details.

Signature:

refreshToken: typeof refreshTokenFn

Example

// Providing a path to a refresh token JSON file
var refreshToken = require("path/to/refreshToken.json");
admin.initializeApp({
  credential: admin.credential.refreshToken(refreshToken),
  databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});

credential.Credential

Interface that provides Google OAuth2 access tokens used to authenticate with Firebase services.

In most cases, you will not need to implement this yourself and can instead use the default implementations provided by the admin.credential namespace.

Signature:

type Credential = TCredential;