firebase_admin_dart library

The shared pieces of the admin libraries of firebase_admin_dart: the app (FirebaseAdminApp), its credential (AdminCredential) and the base exception (FirebaseAdminException). It also exports OAuthTokenProvider and OAuthAccessToken of firebase_auth_providers_dart, the token source of AdminCredential.iam.

The admin calls are in their own libraries: package:firebase_admin_dart/auth.dart for Firebase Auth (it also exports this library). package:firebase_admin_dart/adc.dart (needs dart:io) builds a credential from Application Default Credentials.

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.

The library does not import dart:io and compiles for the web, but a browser is not a place for admin credentials.

import 'package:firebase_admin_dart/firebase_admin_dart.dart';

FirebaseAdminApp emulatorApp() => FirebaseAdminApp.emulator(
  projectId: 'demo-test',
  authEmulatorHost: '127.0.0.1:9099',
);

Classes

AdminCredential
Who the admin calls run as, and how data (custom tokens) gets signed. Pass it to FirebaseAdminApp.
FirebaseAdminApp
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().
OAuthAccessToken
An OAuth 2.0 access token and when it expires: what the fetch function of an OAuthTokenProvider returns.
OAuthTokenProvider
A token provider for servers and command line tools: it hands out Google OAuth 2.0 access tokens (of a service account, or of Application Default Credentials) and gets a new one before the current one expires.

Exceptions / Errors

FirebaseAdminException
The base of the exceptions of firebase_admin_dart: every admin library throws a subclass of it (FirebaseAuthAdminException of auth.dart).