Credential.fromServiceAccount constructor
Credential.fromServiceAccount(
- File serviceAccountFile
Log in to firebase from a service account file.
Implementation
factory Credential.fromServiceAccount(File serviceAccountFile) {
final content = serviceAccountFile.readAsStringSync();
final json = jsonDecode(content);
if (json is! Map<String, Object?>) {
throw const FormatException('Invalid service account file');
}
final serviceAccountCredentials =
auth.ServiceAccountCredentials.fromJson(json);
return Credential._(serviceAccountCredentials);
}