firebase-admin
- Version 13.0.1
- Published
- 1.34 MB
- 10 dependencies
- Apache-2.0 license
Install
npm i firebase-admin
yarn add firebase-admin
pnpm add firebase-admin
Overview
Firebase admin SDK for Node.js
Index
Variables
Functions
Interfaces
Namespaces
auth
- ActionCodeSettings
- Auth
- AuthFactorType
- AuthProviderConfig
- AuthProviderConfigFilter
- BaseAuth
- CreateMultiFactorInfoRequest
- CreatePhoneMultiFactorInfoRequest
- CreateRequest
- CreateTenantRequest
- DecodedAuthBlockingToken
- DecodedIdToken
- DeleteUsersResult
- EmailIdentifier
- EmailSignInProviderConfig
- GetUsersResult
- HashAlgorithmType
- ListProviderConfigResults
- ListTenantsResult
- ListUsersResult
- MultiFactorConfig
- MultiFactorConfigState
- MultiFactorCreateSettings
- MultiFactorInfo
- MultiFactorSettings
- MultiFactorUpdateSettings
- OIDCAuthProviderConfig
- OIDCUpdateAuthProviderRequest
- PhoneIdentifier
- PhoneMultiFactorInfo
- ProviderIdentifier
- SAMLAuthProviderConfig
- SAMLUpdateAuthProviderRequest
- SessionCookieOptions
- Tenant
- TenantAwareAuth
- TenantManager
- UidIdentifier
- UpdateAuthProviderRequest
- UpdateMultiFactorInfoRequest
- UpdatePhoneMultiFactorInfoRequest
- UpdateRequest
- UpdateTenantRequest
- UserIdentifier
- UserImportOptions
- UserImportRecord
- UserImportResult
- UserInfo
- UserMetadata
- UserMetadataRequest
- UserProviderRequest
- UserRecord
messaging
- AndroidConfig
- AndroidFcmOptions
- AndroidNotification
- ApnsConfig
- ApnsFcmOptions
- ApnsPayload
- Aps
- ApsAlert
- BatchResponse
- ConditionMessage
- CriticalSound
- DataMessagePayload
- FcmOptions
- LightSettings
- Message
- Messaging
- MessagingOptions
- MessagingPayload
- MessagingTopicManagementResponse
- MulticastMessage
- Notification
- NotificationMessagePayload
- SendResponse
- TokenMessage
- TopicMessage
- WebpushConfig
- WebpushFcmOptions
- WebpushNotification
Variables
variable apps
const apps: app.App[];
variable SDK_VERSION
const SDK_VERSION: string;
Functions
function app
app: (name?: string) => app.App;
function appCheck
appCheck: (app?: App) => appCheck.AppCheck;
Gets the firebase-admin.app-check#AppCheck service for the default app or a given app.
admin.appCheck()
can be called with no arguments to access the default app'sAppCheck
service or asadmin.appCheck(app)
to access theAppCheck
service associated with a specific app.Parameter app
Optional app for which to return the
AppCheck
service. If not provided, the defaultAppCheck
service is returned.Returns
The default
AppCheck
service if no app is provided, or theAppCheck
service associated with the provided app.Example 1
// Get the `AppCheck` service for the default appvar defaultAppCheck = admin.appCheck();Example 2
// Get the `AppCheck` service for a given appvar otherAppCheck = admin.appCheck(otherApp);
function auth
auth: (app?: App) => auth.Auth;
Gets the firebase-admin.auth#Auth service for the default app or a given app.
admin.auth()
can be called with no arguments to access the default app's firebase-admin.auth#Auth service or asadmin.auth(app)
to access the firebase-admin.auth#Auth service associated with a specific app.Example 1
// Get the Auth service for the default appvar defaultAuth = admin.auth();Example 2
// Get the Auth service for a given appvar otherAuth = admin.auth(otherApp);
function database
database: typeof database;
Gets the firebase-admin.database#Database service for the default app or a given app.
admin.database()
can be called with no arguments to access the default app'sDatabase
service or asadmin.database(app)
to access theDatabase
service associated with a specific app.admin.database
is also a namespace that can be used to access global constants and methods associated with theDatabase
service.Parameter App
whose
Database
service to return. If not provided, the defaultDatabase
service will be returned.Returns
The default
Database
service if no app is provided or theDatabase
service associated with the provided app.Example 1
// Get the Database service for the default appvar defaultDatabase = admin.database();Example 2
// Get the Database service for a specific appvar otherDatabase = admin.database(app);
function firestore
firestore: typeof firestore;
function initializeApp
initializeApp: (options?: AppOptions, name?: string) => app.App;
function installations
installations: (app?: App) => installations.Installations;
Gets the firebase-admin.installations#Installations service for the default app or a given app.
admin.installations()
can be called with no arguments to access the default app's firebase-admin.installations#Installations service or asadmin.installations(app)
to access the firebase-admin.installations#Installations service associated with a specific app.Parameter app
Optional app whose
Installations
service to return. If not provided, the defaultInstallations
service is returned.Returns
The default
Installations
service if no app is provided or theInstallations
service associated with the provided app.Example 1
// Get the Installations service for the default appvar defaultInstallations = admin.installations();Example 2
// Get the Installations service for a given appvar otherInstallations = admin.installations(otherApp);
function instanceId
instanceId: (app?: App) => instanceId.InstanceId;
Gets the firebase-admin.instance-id#InstanceId service for the default app or a given app.
admin.instanceId()
can be called with no arguments to access the default app'sInstanceId
service or asadmin.instanceId(app)
to access theInstanceId
service associated with a specific app.Parameter app
Optional app whose
InstanceId
service to return. If not provided, the defaultInstanceId
service will be returned.Returns
The default
InstanceId
service if no app is provided or theInstanceId
service associated with the provided app.Example 1
// Get the Instance ID service for the default appvar defaultInstanceId = admin.instanceId();Example 2
// Get the Instance ID service for a given appvar otherInstanceId = admin.instanceId(otherApp);
function machineLearning
machineLearning: (app?: App) => machineLearning.MachineLearning;
Gets the firebase-admin.machine-learning#MachineLearning service for the default app or a given app.
admin.machineLearning()
can be called with no arguments to access the default app'sMachineLearning
service or asadmin.machineLearning(app)
to access theMachineLearning
service associated with a specific app.Parameter app
Optional app whose
MachineLearning
service to return. If not provided, the defaultMachineLearning
service will be returned.Returns
The default
MachineLearning
service if no app is provided or theMachineLearning
service associated with the provided app.Example 1
// Get the MachineLearning service for the default appvar defaultMachineLearning = admin.machineLearning();Example 2
// Get the MachineLearning service for a given appvar otherMachineLearning = admin.machineLearning(otherApp);
function messaging
messaging: (app?: App) => messaging.Messaging;
Gets the firebase-admin.messaging#Messaging service for the default app or a given app.
admin.messaging()
can be called with no arguments to access the default app'sMessaging
service or asadmin.messaging(app)
to access theMessaging
service associated with a specific app.Parameter app
Optional app whose
Messaging
service to return. If not provided, the defaultMessaging
service will be returned.Returns
The default
Messaging
service if no app is provided or theMessaging
service associated with the provided app.Example 1
// Get the Messaging service for the default appvar defaultMessaging = admin.messaging();Example 2
// Get the Messaging service for a given appvar otherMessaging = admin.messaging(otherApp);
function projectManagement
projectManagement: (app?: App) => projectManagement.ProjectManagement;
Gets the firebase-admin.project-management#ProjectManagement service for the default app or a given app.
admin.projectManagement()
can be called with no arguments to access the default app'sProjectManagement
service, or asadmin.projectManagement(app)
to access theProjectManagement
service associated with a specific app.Parameter app
Optional app whose
ProjectManagement
service to return. If not provided, the defaultProjectManagement
service will be returned. *Returns
The default
ProjectManagement
service if no app is provided or theProjectManagement
service associated with the provided app.Example 1
// Get the ProjectManagement service for the default appvar defaultProjectManagement = admin.projectManagement();Example 2
// Get the ProjectManagement service for a given appvar otherProjectManagement = admin.projectManagement(otherApp);
function remoteConfig
remoteConfig: (app?: App) => remoteConfig.RemoteConfig;
Gets the firebase-admin.remote-config#RemoteConfig service for the default app or a given app.
admin.remoteConfig()
can be called with no arguments to access the default app'sRemoteConfig
service or asadmin.remoteConfig(app)
to access theRemoteConfig
service associated with a specific app.Parameter app
Optional app for which to return the
RemoteConfig
service. If not provided, the defaultRemoteConfig
service is returned.Returns
The default
RemoteConfig
service if no app is provided, or theRemoteConfig
service associated with the provided app.Example 1
// Get the `RemoteConfig` service for the default appvar defaultRemoteConfig = admin.remoteConfig();Example 2
// Get the `RemoteConfig` service for a given appvar otherRemoteConfig = admin.remoteConfig(otherApp);
function securityRules
securityRules: (app?: App) => securityRules.SecurityRules;
Gets the firebase-admin.security-rules#SecurityRules service for the default app or a given app.
admin.securityRules()
can be called with no arguments to access the default app's firebase-admin.security-rules#SecurityRules service, or asadmin.securityRules(app)
to access the firebase-admin.security-rules#SecurityRules service associated with a specific app.Parameter app
Optional app to return the
SecurityRules
service for. If not provided, the defaultSecurityRules
service is returned.Returns
The default
SecurityRules
service if no app is provided, or theSecurityRules
service associated with the provided app.Example 1
// Get the SecurityRules service for the default appvar defaultSecurityRules = admin.securityRules();Example 2
// Get the SecurityRules service for a given appvar otherSecurityRules = admin.securityRules(otherApp);
function storage
storage: (app?: App) => storage.Storage;
Gets the firebase-admin.storage#Storage service for the default app or a given app.
admin.storage()
can be called with no arguments to access the default app'sStorage
service or asadmin.storage(app)
to access theStorage
service associated with a specific app.Example 1
// Get the Storage service for the default appvar defaultStorage = admin.storage();Example 2
// Get the Storage service for a given appvar otherStorage = admin.storage(otherApp);
Interfaces
interface AppOptions
interface AppOptions {}
Available options to pass to firebase-admin.app#initializeApp.
property credential
credential?: Credential;
A firebase-admin.app#Credential object used to authenticate the Admin SDK.
See Initialize the SDK for detailed documentation and code samples.
property databaseAuthVariableOverride
databaseAuthVariableOverride?: object | null;
The object to use as the auth variable in your Realtime Database Rules when the Admin SDK reads from or writes to the Realtime Database. This allows you to downscope the Admin SDK from its default full read and write privileges.
You can pass
null
to act as an unauthenticated client.See Authenticate with limited privileges for detailed documentation and code samples.
property databaseURL
databaseURL?: string;
The URL of the Realtime Database from which to read and write data.
property httpAgent
httpAgent?: Agent;
An HTTP Agent to be used when making outgoing HTTP calls. This Agent instance is used by all services that make REST calls (e.g.
auth
,messaging
,projectManagement
).Realtime Database and Firestore use other means of communicating with the backend servers, so they do not use this HTTP Agent.
Credential
instances also do not use this HTTP Agent, but instead support specifying an HTTP Agent in the corresponding factory methods.
property projectId
projectId?: string;
The ID of the Google Cloud project associated with the App.
property serviceAccountId
serviceAccountId?: string;
The ID of the service account to be used for signing custom tokens. This can be found in the
client_email
field of a service account JSON file.
property storageBucket
storageBucket?: string;
The name of the Google Cloud Storage bucket used for storing application data. Use only the bucket name without any prefixes or additions (do *not* prefix the name with "gs://").
interface FirebaseArrayIndexError
interface FirebaseArrayIndexError {}
Composite type which includes both a
FirebaseError
object and an index which can be used to get the errored item.Example 1
var registrationTokens = [token1, token2, token3];admin.messaging().subscribeToTopic(registrationTokens, 'topic-name').then(function(response) {if (response.failureCount > 0) {console.log("Following devices unsucessfully subscribed to topic:");response.errors.forEach(function(error) {var invalidToken = registrationTokens[error.index];console.log(invalidToken, error.error);});} else {console.log("All devices successfully subscribed to topic:", response);}}).catch(function(error) {console.log("Error subscribing to topic:", error);});
interface FirebaseError
interface FirebaseError {}
FirebaseError
is a subclass of the standard JavaScriptError
object. In addition to a message string and stack trace, it contains a string code.
property code
code: string;
Error codes are strings using the following format:
"service/string-code"
. Some examples include"auth/invalid-uid"
and"messaging/invalid-recipient"
.While the message for a given error can change, the code will remain the same between backward-compatible versions of the Firebase SDK.
property message
message: string;
An explanatory message for the error that just occurred.
This message is designed to be helpful to you, the developer. Because it generally does not convey meaningful information to end users, this message should not be displayed in your application.
property stack
stack?: string;
A string value containing the execution backtrace when the error originally occurred.
This information can be useful for troubleshooting the cause of the error with Firebase Support.
method toJSON
toJSON: () => object;
Returns a JSON-serializable object representation of this error.
Returns
A JSON-serializable representation of this object.
interface GoogleOAuthAccessToken
interface GoogleOAuthAccessToken {}
Interface for Google OAuth 2.0 access tokens.
property access_token
access_token: string;
property expires_in
expires_in: number;
interface ServiceAccount
interface ServiceAccount {}
property clientEmail
clientEmail?: string;
property privateKey
privateKey?: string;
property projectId
projectId?: string;
Namespaces
namespace app
namespace app {}
interface App
interface App extends AppCore {}
A Firebase app holds the initialization information for a collection of services.
Do not call this constructor directly. Instead, use firebase-admin.app#initializeApp to create an app.
method appCheck
appCheck: () => appCheck.AppCheck;
method auth
auth: () => auth.Auth;
method database
database: (url?: string) => database.Database;
method delete
delete: () => Promise<void>;
Renders this local
FirebaseApp
unusable and frees the resources of all associated services (though it does *not* clean up any backend resources). When running the SDK locally, this method must be called to ensure graceful termination of the process.Example 1
app.delete().then(function() {console.log("App deleted successfully");}).catch(function(error) {console.log("Error deleting app:", error);});
method firestore
firestore: () => firestore.Firestore;
method installations
installations: () => installations.Installations;
method instanceId
instanceId: () => instanceId.InstanceId;
Deprecated
Use firebase-admin.installations#Installations instead.
method machineLearning
machineLearning: () => machineLearning.MachineLearning;
method messaging
messaging: () => messaging.Messaging;
method projectManagement
projectManagement: () => projectManagement.ProjectManagement;
method remoteConfig
remoteConfig: () => remoteConfig.RemoteConfig;
method securityRules
securityRules: () => securityRules.SecurityRules;
method storage
storage: () => storage.Storage;
namespace appCheck
namespace appCheck {}
type AppCheck
type AppCheck = TAppCheck;
Type alias to firebase-admin.app-check#AppCheck.
type AppCheckToken
type AppCheckToken = TAppCheckToken;
Type alias to firebase-admin.app-check#AppCheckToken.
type AppCheckTokenOptions
type AppCheckTokenOptions = TAppCheckTokenOptions;
Type alias to firebase-admin.app-check#AppCheckTokenOptions.
type DecodedAppCheckToken
type DecodedAppCheckToken = TDecodedAppCheckToken;
Type alias to firebase-admin.app-check#DecodedAppCheckToken.
type VerifyAppCheckTokenOptions
type VerifyAppCheckTokenOptions = TVerifyAppCheckTokenOptions;
Type alias to firebase-admin.app-check#VerifyAppCheckTokenOptions.
type VerifyAppCheckTokenResponse
type VerifyAppCheckTokenResponse = TVerifyAppCheckTokenResponse;
Type alias to firebase-admin.app-check#VerifyAppCheckTokenResponse.
namespace auth
namespace auth {}
type ActionCodeSettings
type ActionCodeSettings = TActionCodeSettings;
Type alias to firebase-admin.auth#ActionCodeSettings.
type Auth
type Auth = TAuth;
Type alias to firebase-admin.auth#Auth.
type AuthFactorType
type AuthFactorType = TAuthFactorType;
Type alias to firebase-admin.auth#AuthFactorType.
type AuthProviderConfig
type AuthProviderConfig = TAuthProviderConfig;
Type alias to firebase-admin.auth#AuthProviderConfig.
type AuthProviderConfigFilter
type AuthProviderConfigFilter = TAuthProviderConfigFilter;
Type alias to firebase-admin.auth#AuthProviderConfigFilter.
type BaseAuth
type BaseAuth = TBaseAuth;
Type alias to firebase-admin.auth#BaseAuth.
type CreateMultiFactorInfoRequest
type CreateMultiFactorInfoRequest = TCreateMultiFactorInfoRequest;
Type alias to firebase-admin.auth#CreateMultiFactorInfoRequest.
type CreatePhoneMultiFactorInfoRequest
type CreatePhoneMultiFactorInfoRequest = TCreatePhoneMultiFactorInfoRequest;
Type alias to firebase-admin.auth#CreatePhoneMultiFactorInfoRequest.
type CreateRequest
type CreateRequest = TCreateRequest;
Type alias to firebase-admin.auth#CreateRequest.
type CreateTenantRequest
type CreateTenantRequest = TCreateTenantRequest;
Type alias to firebase-admin.auth#CreateTenantRequest.
type DecodedAuthBlockingToken
type DecodedAuthBlockingToken = TDecodedAuthBlockingToken;
Modifiers
@alpha
type DecodedIdToken
type DecodedIdToken = TDecodedIdToken;
Type alias to firebase-admin.auth#DecodedIdToken.
type DeleteUsersResult
type DeleteUsersResult = TDeleteUsersResult;
Type alias to firebase-admin.auth#DeleteUsersResult.
type EmailIdentifier
type EmailIdentifier = TEmailIdentifier;
Type alias to firebase-admin.auth#EmailIdentifier.
type EmailSignInProviderConfig
type EmailSignInProviderConfig = TEmailSignInProviderConfig;
Type alias to firebase-admin.auth#EmailSignInProviderConfig.
type GetUsersResult
type GetUsersResult = TGetUsersResult;
Type alias to firebase-admin.auth#GetUsersResult.
type HashAlgorithmType
type HashAlgorithmType = THashAlgorithmType;
Type alias to firebase-admin.auth#HashAlgorithmType.
type ListProviderConfigResults
type ListProviderConfigResults = TListProviderConfigResults;
Type alias to firebase-admin.auth#ListProviderConfigResults.
type ListTenantsResult
type ListTenantsResult = TListTenantsResult;
Type alias to firebase-admin.auth#ListTenantsResult.
type ListUsersResult
type ListUsersResult = TListUsersResult;
Type alias to firebase-admin.auth#ListUsersResult.
type MultiFactorConfig
type MultiFactorConfig = TMultiFactorConfig;
Type alias to firebase-admin.auth#MultiFactorConfig.
type MultiFactorConfigState
type MultiFactorConfigState = TMultiFactorConfigState;
Type alias to firebase-admin.auth#MultiFactorConfigState.
type MultiFactorCreateSettings
type MultiFactorCreateSettings = TMultiFactorCreateSettings;
Type alias to firebase-admin.auth#MultiFactorCreateSettings.
type MultiFactorInfo
type MultiFactorInfo = TMultiFactorInfo;
Type alias to firebase-admin.auth#MultiFactorInfo.
type MultiFactorSettings
type MultiFactorSettings = TMultiFactorSettings;
Type alias to firebase-admin.auth#MultiFactorSettings.
type MultiFactorUpdateSettings
type MultiFactorUpdateSettings = TMultiFactorUpdateSettings;
Type alias to firebase-admin.auth#MultiFactorUpdateSettings.
type OIDCAuthProviderConfig
type OIDCAuthProviderConfig = TOIDCAuthProviderConfig;
Type alias to firebase-admin.auth#OIDCAuthProviderConfig.
type OIDCUpdateAuthProviderRequest
type OIDCUpdateAuthProviderRequest = TOIDCUpdateAuthProviderRequest;
Type alias to firebase-admin.auth#OIDCUpdateAuthProviderRequest.
type PhoneIdentifier
type PhoneIdentifier = TPhoneIdentifier;
Type alias to firebase-admin.auth#PhoneIdentifier.
type PhoneMultiFactorInfo
type PhoneMultiFactorInfo = TPhoneMultiFactorInfo;
Type alias to firebase-admin.auth#PhoneMultiFactorInfo.
type ProviderIdentifier
type ProviderIdentifier = TProviderIdentifier;
Type alias to firebase-admin.auth#ProviderIdentifier.
type SAMLAuthProviderConfig
type SAMLAuthProviderConfig = TSAMLAuthProviderConfig;
Type alias to firebase-admin.auth#SAMLAuthProviderConfig.
type SAMLUpdateAuthProviderRequest
type SAMLUpdateAuthProviderRequest = TSAMLUpdateAuthProviderRequest;
Type alias to firebase-admin.auth#SAMLUpdateAuthProviderRequest.
type SessionCookieOptions
type SessionCookieOptions = TSessionCookieOptions;
Type alias to firebase-admin.auth#SessionCookieOptions.
type Tenant
type Tenant = TTenant;
Type alias to firebase-admin.auth#Tenant.
type TenantAwareAuth
type TenantAwareAuth = TTenantAwareAuth;
Type alias to firebase-admin.auth#TenantAwareAuth.
type TenantManager
type TenantManager = TTenantManager;
Type alias to firebase-admin.auth#TenantManager.
type UidIdentifier
type UidIdentifier = TUidIdentifier;
Type alias to firebase-admin.auth#UidIdentifier.
type UpdateAuthProviderRequest
type UpdateAuthProviderRequest = TUpdateAuthProviderRequest;
Type alias to firebase-admin.auth#UpdateAuthProviderRequest.
type UpdateMultiFactorInfoRequest
type UpdateMultiFactorInfoRequest = TUpdateMultiFactorInfoRequest;
Type alias to firebase-admin.auth#UpdateMultiFactorInfoRequest.
type UpdatePhoneMultiFactorInfoRequest
type UpdatePhoneMultiFactorInfoRequest = TUpdatePhoneMultiFactorInfoRequest;
Type alias to firebase-admin.auth#UpdatePhoneMultiFactorInfoRequest.
type UpdateRequest
type UpdateRequest = TUpdateRequest;
Type alias to firebase-admin.auth#UpdateRequest.
type UpdateTenantRequest
type UpdateTenantRequest = TUpdateTenantRequest;
Type alias to firebase-admin.auth#UpdateTenantRequest.
type UserIdentifier
type UserIdentifier = TUserIdentifier;
Type alias to firebase-admin.auth#UserIdentifier.
type UserImportOptions
type UserImportOptions = TUserImportOptions;
Type alias to firebase-admin.auth#UserImportOptions.
type UserImportRecord
type UserImportRecord = TUserImportRecord;
Type alias to firebase-admin.auth#UserImportRecord.
type UserImportResult
type UserImportResult = TUserImportResult;
Type alias to firebase-admin.auth#UserImportResult.
type UserInfo
type UserInfo = TUserInfo;
Type alias to firebase-admin.auth#UserInfo.
type UserMetadata
type UserMetadata = TUserMetadata;
Type alias to firebase-admin.auth#UserMetadata.
type UserMetadataRequest
type UserMetadataRequest = TUserMetadataRequest;
Type alias to firebase-admin.auth#UserMetadataRequest.
type UserProviderRequest
type UserProviderRequest = TUserProviderRequest;
Type alias to firebase-admin.auth#UserProviderRequest.
type UserRecord
type UserRecord = TUserRecord;
Type alias to firebase-admin.auth#UserRecord.
namespace credential
namespace credential {}
variable applicationDefault
const applicationDefault: (httpAgent?: Agent) => TCredential;
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 firebase-admin.app#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.
Parameter httpAgent
Optional HTTP Agent to be used when retrieving access tokens from Google token servers.
Returns
A credential authenticated via Google Application Default Credentials that can be used to initialize an app.
Example 1
admin.initializeApp({credential: admin.credential.applicationDefault(),databaseURL: "https://<DATABASE_NAME>.firebaseio.com"});
variable cert
const cert: ( serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent) => TCredential;
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 firebase-admin.app#initializeApp.
See Initialize the SDK for more details.
Parameter serviceAccountPathOrObject
The path to a service account key JSON file or an object representing a service account key.
Parameter httpAgent
Optional 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.
Example 1
// Providing a path to a service account key JSON filevar 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 inlineadmin.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"});
variable refreshToken
const refreshToken: ( refreshTokenPathOrObject: string | object, httpAgent?: Agent) => TCredential;
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.
Parameter refreshTokenPathOrObject
The path to a Google OAuth2 refresh token JSON file or an object representing a Google OAuth2 refresh token.
Parameter httpAgent
Optional 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.
Example 1
// Providing a path to a refresh token JSON filevar refreshToken = require("path/to/refreshToken.json");admin.initializeApp({credential: admin.credential.refreshToken(refreshToken),databaseURL: "https://<DATABASE_NAME>.firebaseio.com"});
type Credential
type Credential = TCredential;
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.
namespace database
namespace database {}
variable enableLogging
const enableLogging: any;
enableLogging function from the
@firebase/database-compat
package.
variable ServerValue
const ServerValue: rtdb.ServerValue;
ServerValue constant from the
@firebase/database-compat
package.
type Database
type Database = TDatabase;
Type alias to firebase-admin.database#Database.
type DataSnapshot
type DataSnapshot = rtdb.DataSnapshot;
Type alias to DataSnapshot type from the
@firebase/database-compat
package.
type EventType
type EventType = rtdb.EventType;
Type alias to the EventType type from the
@firebase/database-compat
package.
type OnDisconnect
type OnDisconnect = rtdb.OnDisconnect;
Type alias to OnDisconnect type from the
@firebase/database-compat
package.
type Query
type Query = rtdb.Query;
Type alias to Query type from the
@firebase/database-compat
package.
type Reference
type Reference = rtdb.Reference;
Type alias to Reference type from the
@firebase/database-compat
package.
type ThenableReference
type ThenableReference = rtdb.ThenableReference;
Type alias to ThenableReference type from the
@firebase/database-compat
package.
namespace firestore
namespace firestore {}
namespace installations
namespace installations {}
type Installations
type Installations = TInstallations;
Type alias to firebase-admin.installations#Installations.
namespace instanceId
namespace instanceId {}
type InstanceId
type InstanceId = TInstanceId;
Type alias to firebase-admin.instance-id#InstanceId.
namespace machineLearning
namespace machineLearning {}
type GcsTfliteModelOptions
type GcsTfliteModelOptions = TGcsTfliteModelOptions;
Type alias to firebase-admin.machine-learning#GcsTfliteModelOptions.
type ListModelsOptions
type ListModelsOptions = TListModelsOptions;
Type alias to firebase-admin.machine-learning#ListModelsOptions.
type ListModelsResult
type ListModelsResult = TListModelsResult;
Type alias to firebase-admin.machine-learning#ListModelsResult.
type MachineLearning
type MachineLearning = TMachineLearning;
Type alias to firebase-admin.machine-learning#MachineLearning.
type Model
type Model = TModel;
Type alias to firebase-admin.machine-learning#Model.
type ModelOptions
type ModelOptions = TModelOptions;
Type alias to firebase-admin.machine-learning#ModelOptions.
type ModelOptionsBase
type ModelOptionsBase = TModelOptionsBase;
Type alias to firebase-admin.machine-learning#ModelOptionsBase.
type TFLiteModel
type TFLiteModel = TTFLiteModel;
Type alias to firebase-admin.machine-learning#TFLiteModel.
namespace messaging
namespace messaging {}
type AndroidConfig
type AndroidConfig = TAndroidConfig;
Type alias to firebase-admin.messaging#AndroidConfig.
type AndroidFcmOptions
type AndroidFcmOptions = TAndroidFcmOptions;
Type alias to firebase-admin.messaging#AndroidFcmOptions.
type AndroidNotification
type AndroidNotification = TAndroidNotification;
Type alias to firebase-admin.messaging#AndroidNotification.
type ApnsConfig
type ApnsConfig = TApnsConfig;
Type alias to firebase-admin.messaging#ApnsConfig.
type ApnsFcmOptions
type ApnsFcmOptions = TApnsFcmOptions;
Type alias to firebase-admin.messaging#ApnsFcmOptions.
type ApnsPayload
type ApnsPayload = TApnsPayload;
Type alias to firebase-admin.messaging#ApnsPayload.
type Aps
type Aps = TAps;
Type alias to firebase-admin.messaging#Aps.
type ApsAlert
type ApsAlert = TApsAlert;
Type alias to firebase-admin.messaging#ApsAlert.
type BatchResponse
type BatchResponse = TBatchResponse;
Type alias to firebase-admin.messaging#BatchResponse.
type ConditionMessage
type ConditionMessage = TConditionMessage;
Type alias to firebase-admin.messaging#ConditionMessage.
type CriticalSound
type CriticalSound = TCriticalSound;
Type alias to firebase-admin.messaging#CriticalSound.
type DataMessagePayload
type DataMessagePayload = TDataMessagePayload;
Type alias to firebase-admin.messaging#DataMessagePayload.
type FcmOptions
type FcmOptions = TFcmOptions;
Type alias to firebase-admin.messaging#FcmOptions.
type LightSettings
type LightSettings = TLightSettings;
Type alias to firebase-admin.messaging#LightSettings.
type Message
type Message = TMessage;
Type alias to firebase-admin.messaging#Message.
type Messaging
type Messaging = TMessaging;
Type alias to firebase-admin.messaging#Messaging.
type MessagingOptions
type MessagingOptions = TMessagingOptions;
Type alias to firebase-admin.messaging#MessagingOptions.
type MessagingPayload
type MessagingPayload = TMessagingPayload;
Type alias to firebase-admin.messaging#MessagingPayload.
type MessagingTopicManagementResponse
type MessagingTopicManagementResponse = TMessagingTopicManagementResponse;
Type alias to firebase-admin.messaging#MessagingTopicManagementResponse.
type MulticastMessage
type MulticastMessage = TMulticastMessage;
Type alias to firebase-admin.messaging#MulticastMessage.
type Notification
type Notification = TNotification;
Type alias to firebase-admin.messaging#Notification.
type NotificationMessagePayload
type NotificationMessagePayload = TNotificationMessagePayload;
Type alias to firebase-admin.messaging#NotificationMessagePayload.
type SendResponse
type SendResponse = TSendResponse;
Type alias to firebase-admin.messaging#SendResponse.
type TokenMessage
type TokenMessage = TTokenMessage;
Type alias to firebase-admin.messaging#TokenMessage.
type TopicMessage
type TopicMessage = TTopicMessage;
Type alias to firebase-admin.messaging#TopicMessage.
type WebpushConfig
type WebpushConfig = TWebpushConfig;
Type alias to firebase-admin.messaging#WebpushConfig.
type WebpushFcmOptions
type WebpushFcmOptions = TWebpushFcmOptions;
Type alias to firebase-admin.messaging#WebpushFcmOptions.
type WebpushNotification
type WebpushNotification = TWebpushNotification;
Type alias to firebase-admin.messaging#WebpushNotification.
namespace projectManagement
namespace projectManagement {}
type AndroidApp
type AndroidApp = TAndroidApp;
Type alias to firebase-admin.project-management#AndroidApp.
type AndroidAppMetadata
type AndroidAppMetadata = TAndroidAppMetadata;
Type alias to firebase-admin.project-management#AndroidAppMetadata.
type AppMetadata
type AppMetadata = TAppMetadata;
Type alias to firebase-admin.project-management#AppMetadata.
type AppPlatform
type AppPlatform = TAppPlatform;
Type alias to firebase-admin.project-management#AppPlatform.
type IosApp
type IosApp = TIosApp;
Type alias to firebase-admin.project-management#IosApp.
type IosAppMetadata
type IosAppMetadata = TIosAppMetadata;
Type alias to firebase-admin.project-management#IosAppMetadata.
type ProjectManagement
type ProjectManagement = TProjectManagement;
Type alias to firebase-admin.project-management#ProjectManagement.
type ShaCertificate
type ShaCertificate = TShaCertificate;
Type alias to firebase-admin.project-management#ShaCertificate.
namespace remoteConfig
namespace remoteConfig {}
type ExplicitParameterValue
type ExplicitParameterValue = TExplicitParameterValue;
Type alias to firebase-admin.remote-config#ExplicitParameterValue.
type InAppDefaultValue
type InAppDefaultValue = TInAppDefaultValue;
Type alias to firebase-admin.remote-config#InAppDefaultValue.
type ListVersionsOptions
type ListVersionsOptions = TListVersionsOptions;
Type alias to firebase-admin.remote-config#ListVersionsOptions.
type ListVersionsResult
type ListVersionsResult = TListVersionsResult;
Type alias to firebase-admin.remote-config#ListVersionsResult.
type ParameterValueType
type ParameterValueType = TParameterValueType;
Type alias to firebase-admin.remote-config#ParameterValueType.
type RemoteConfig
type RemoteConfig = TRemoteConfig;
Type alias to firebase-admin.remote-config#RemoteConfig.
type RemoteConfigCondition
type RemoteConfigCondition = TRemoteConfigCondition;
Type alias to firebase-admin.remote-config#RemoteConfigCondition.
type RemoteConfigParameter
type RemoteConfigParameter = TRemoteConfigParameter;
Type alias to firebase-admin.remote-config#RemoteConfigParameter.
type RemoteConfigParameterGroup
type RemoteConfigParameterGroup = TRemoteConfigParameterGroup;
Type alias to firebase-admin.remote-config#RemoteConfigParameterGroup.
type RemoteConfigParameterValue
type RemoteConfigParameterValue = TRemoteConfigParameterValue;
Type alias to firebase-admin.remote-config#RemoteConfigParameterValue.
type RemoteConfigTemplate
type RemoteConfigTemplate = TRemoteConfigTemplate;
Type alias to firebase-admin.remote-config#RemoteConfigTemplate.
type RemoteConfigUser
type RemoteConfigUser = TRemoteConfigUser;
Type alias to firebase-admin.remote-config#RemoteConfigUser.
type TagColor
type TagColor = TTagColor;
Type alias to firebase-admin.remote-config#TagColor.
type Version
type Version = TVersion;
Type alias to firebase-admin.remote-config#Version.
namespace securityRules
namespace securityRules {}
type Ruleset
type Ruleset = TRuleset;
Type alias to firebase-admin.security-rules#Ruleset.
type RulesetMetadata
type RulesetMetadata = TRulesetMetadata;
Type alias to firebase-admin.security-rules#RulesetMetadata.
type RulesetMetadataList
type RulesetMetadataList = TRulesetMetadataList;
Type alias to firebase-admin.security-rules#RulesetMetadataList.
type RulesFile
type RulesFile = TRulesFile;
Type alias to firebase-admin.security-rules#RulesFile.
type SecurityRules
type SecurityRules = TSecurityRules;
Type alias to firebase-admin.security-rules#SecurityRules.
namespace storage
namespace storage {}
type Storage
type Storage = TStorage;
Type alias to firebase-admin.storage#Storage.
Package Files (17)
- lib/app-check/app-check-namespace.d.ts
- lib/app/core.d.ts
- lib/app/credential.d.ts
- lib/auth/auth-namespace.d.ts
- lib/credential/index.d.ts
- lib/database/database-namespace.d.ts
- lib/firebase-namespace-api.d.ts
- lib/firestore/firestore-namespace.d.ts
- lib/index.d.ts
- lib/installations/installations-namespace.d.ts
- lib/instance-id/instance-id-namespace.d.ts
- lib/machine-learning/machine-learning-namespace.d.ts
- lib/messaging/messaging-namespace.d.ts
- lib/project-management/project-management-namespace.d.ts
- lib/remote-config/remote-config-namespace.d.ts
- lib/security-rules/security-rules-namespace.d.ts
- lib/storage/storage-namespace.d.ts
Dependencies (10)
Dev Dependencies (50)
- @firebase/api-documenter
- @firebase/app-compat
- @firebase/auth-compat
- @firebase/auth-types
- @microsoft/api-extractor
- @types/bcrypt
- @types/chai
- @types/chai-as-promised
- @types/firebase-token-generator
- @types/jsonwebtoken
- @types/lodash
- @types/minimist
- @types/mocha
- @types/nock
- @types/request
- @types/request-promise
- @types/sinon
- @types/sinon-chai
- @types/uuid
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- bcrypt
- chai
- chai-as-promised
- chai-exclude
- chalk
- child-process-promise
- del
- eslint
- firebase-token-generator
- gulp
- gulp-filter
- gulp-header
- gulp-typescript
- http-message-parser
- lodash
- minimist
- mocha
- mz
- nock
- npm-run-all
- nyc
- request
- request-promise
- run-sequence
- sinon
- sinon-chai
- ts-node
- typescript
- yargs
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/firebase-admin
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/firebase-admin)
- HTML<a href="https://www.jsdocs.io/package/firebase-admin"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4819 ms. - Missing or incorrect documentation? Open an issue for this package.