FirebaseAdminApp class
One Firebase project as an administrator reaches it: the project id, the credential, the emulators to use,
and the HTTP client. The admin libraries take it: FirebaseAuthAdmin(app) of auth.dart, or app.auth().
The Admin SDKs call this an app (initializeApp in Node.js); it is named FirebaseAdminApp so that it does
not collide with FirebaseApp of firebase_app_dart or FlutterFire when a file imports both.
For trusted code only: servers, CLIs, CI jobs and integration tests. Admin credentials bypass security rules and can act as any user. Never put a service account key in an app, a web page, a Flutter asset of a release build or a repository; on Google Cloud prefer Application Default Credentials with AdminCredential.iam, which holds no key.
import 'package:firebase_admin_dart/auth.dart';
Future<void> main() async {
final FirebaseAdminApp app = FirebaseAdminApp.emulator(
projectId: 'demo-test',
authEmulatorHost: '127.0.0.1:9099',
);
final AdminUser user = await app.auth().createUser();
print(user.uid);
await app.close();
}
- Available extensions
Constructors
- FirebaseAdminApp({required String projectId, required AdminCredential credential, Client? httpClient, DateTime clock()?})
-
Admin calls for the project
projectIdwithcredential. - FirebaseAdminApp.emulator({required String projectId, required String authEmulatorHost, Client? httpClient, DateTime clock()?})
-
Admin calls against the Firebase emulators, for the project
projectId(any id; use ademo-id, which never reaches a real project).authEmulatorHost(host:port, orhttp://host:port) is the Auth emulator.
Properties
- authEmulatorHost → String?
-
The Auth emulator as it was passed to FirebaseAdminApp.emulator, or null.
final
- credential → AdminCredential?
-
The credential, or null for FirebaseAdminApp.emulator.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether close was called.
no setter
- isEmulator → bool
-
Whether the calls go to the emulators (FirebaseAdminApp.emulator).
no setter
- projectId → String
-
The project the calls are for.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
auth(
) → FirebaseAuthAdmin -
Available on FirebaseAdminApp, provided by the FirebaseAdminAppAuth extension
The FirebaseAuthAdmin of this app, the same object asFirebaseAuthAdmin(app). -
close(
) → Future< void> - Ends the use of this app and of the admin objects made from it: closes the HTTP client if the app created it. Calls after close throw a StateError.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- emulatorServiceAccount → const String
- The issuer of the data signed in emulator mode, as the Node Admin SDK names it.