AdminCredential.serviceAccount constructor
AdminCredential.serviceAccount(
- Object json
A service account key: json is the decoded content of the key file (a Map) or the content itself (a
String), as you loaded it. The package never reads a file or an environment variable for it.
Throws an ArgumentError if json is not a service account key (the error does not quote it).
import 'dart:convert';
import 'dart:io';
import 'package:firebase_admin_dart/firebase_admin_dart.dart';
FirebaseAdminApp appFromKeyFile(String path) {
final Map<String, Object?> key =
jsonDecode(File(path).readAsStringSync()) as Map<String, Object?>;
return FirebaseAdminApp(
projectId: key['project_id']! as String,
credential: AdminCredential.serviceAccount(key),
);
}
Implementation
factory AdminCredential.serviceAccount(Object json) =
ServiceAccountCredential;