• 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 firebase-admin.app#initializeApp.

    See Initialize the SDK for more details.

    Parameters

    • refreshTokenPathOrObject: string | object

      The path to a Google OAuth2 refresh token JSON file or an object representing a Google OAuth2 refresh token.

    • Optional httpAgent: Agent

      Optional HTTP Agent to be used when retrieving access tokens from Google token servers.

    Returns Credential

    A credential authenticated via the provided service account that can be used to initialize an app.

    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"
    });