搜索插件、代码仓与 APP 分类

插件详情v0.3.1+5

firebase_admin

Firebase Admin SDK 的纯 Dart 代码移植版本,符合 Dart 语言习惯

AndroidiOSmacOSWindowsLinux
近 30 天下载
1200
喜欢数
98
Pub 分数
150

安装插件

flutter pub add firebase_admin

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

firebase_admin 包提供了一个纯正且符合 Dart 语言习惯的 Firebase Admin SDK 实现,使服务器端能够与 Firebase 服务进行交互。它允许开发者认证用户、管理 Firebase 项目,并从基于 Dart 的后端执行用户管理、令牌验证和数据库操作等管理任务。该包专为非浏览器环境(如服务器、CLI 工具或桌面应用程序)设计,支持所有主要平台,包括 Android、iOS、macOS、Windows 和 Linux。该包非常适合将 Firebase 功能集成到自定义后端系统中,而无需依赖 JavaScript 或外部依赖项。

适合场景

  • 服务器端 Firebase 管理
  • 通过 Firebase Auth 进行用户管理
  • 令牌验证和验证
  • 与 Firebase Firestore 的后端集成
  • 自动 Firebase 项目设置

主要特点

  • 纯 Dart 实现
  • 跨平台支持
  • 惯用的 Dart API
  • 安全访问 Firebase Admin
  • 支持所有 Firebase 服务

适合对象

  • 使用 Dart 的后端开发人员
  • 使用 Firebase 的无服务器函数
  • 需要 Firebase 访问权限的桌面应用程序
  • 自定义身份验证系统
  • 需要 Firebase 自动化的 CI/CD 流水线

使用建议

  • 需要服务账户凭据
  • 不适用于客户端应用程序
  • 需要对私钥进行安全处理
  • 仅限管理员操作
  • 可能需要特定于平台的配置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Ceasefire Now

A pure Dart implementation of the Firebase admin sdk

Currently, only supports admin methods for the following firebase services:

  • authentication
  • realtime database

Example using service account

import 'package:firebase_admin/firebase_admin.dart';

main() async {
  var app = FirebaseAdmin.instance.initializeApp(AppOptions(
    credential: ServiceAccountCredential('service-account.json'),
  ));

  var link = await app.auth().generateSignInWithEmailLink('jane@doe.com',
      ActionCodeSettings(url: 'https://example.com'));

  print(link);
}

Example using default credentials

import 'package:firebase_admin/firebase_admin.dart';
import 'package:firebase_admin/src/credential.dart';

void main() async {
  // applicationDefault() will look for credentials in the following locations:
  // * the env variable GOOGLE_APPLICATION_CREDENTIALS
  // * a configuration file, specific for this library, stored in the user's home directory
  // * gcloud's application default credentials
  // * credentials from the firebase tools
  var credential = Credentials.applicationDefault();

  // when no credentials found, login using openid
  // the credentials are stored on disk for later use
  credential ??= await Credentials.login();

  // create an app
  var app = FirebaseAdmin.instance.initializeApp(AppOptions(
      credential: credential ?? Credentials.applicationDefault(),
      projectId: 'some-project'));

  try {
    // get a user by email
    var v = await app.auth().getUserByEmail('jane@doe.com');
    print(v.toJson());
  } on FirebaseException catch (e) {
    print(e.message);
  }
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Sponsor

Creating and maintaining this package takes a lot of time. If you like the result, please consider to :heart: sponsor. With your support, I will be able to further improve and support this project. Also, check out my other dart packages at pub.dev.

所属分类

依赖

依赖清单 16 项

源码仓库

使用此插件的项目