搜尋分類、套件與程式碼儲存庫

套件詳情v2.1.5

firebase_auth_rest

基於 REST 的跨平台 Dart/Flutter 包裝程式,用於 Firebase 身份驗證 API

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
292
喜歡數
23
Pub 分數
150

安裝套件

flutter pub add firebase_auth_rest

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個與平台無關的 Dart/Flutter 包裝器,用於 Firebase Authentication REST API,可於 Android、iOS、Web、macOS、Windows 及 Linux 上實現無縫驗證。它將 Firebase 的 REST 端點抽象為簡潔易用的介面,無需使用原生 SDK。非常適合希望以最少設定實現跨平台驗證並完全掌控驗證流程的開發者。此套件輕量且設計用於在無法使用原生 Firebase SDK 的環境中可靠運行。

適用情境

  • 跨平台身分驗證
  • 伺服器端驗證整合
  • Web 和桌面應用程式驗證
  • 自定義驗證流程
  • 離線優先的應用程式

主要特色

  • 基於 REST 的 Firebase 集成
  • 多平台支援
  • 無原生 SDK 依賴
  • 簡單的 API 表面
  • 安全的令牌處理

適合對象

  • 面向多個平台的開發者
  • 項目避免使用原生 Firebase SDK
  • 需要對身份驗證進行細粒度控制的應用程式
  • 後端整合的 Flutter 應用
  • 輕量級身分驗證解決方案

使用建議

  • 需要手動管理刷新權杖
  • 僅限 REST API 功能
  • 無內建 UI 組件
  • 取決於網路可用性
  • REST 呼叫需要適當的錯誤處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

firebase_auth_rest

CI/CD Pub Version

A platform independent Dart/Flutter Wrapper for the Firebase Authentication API based on REST

Features

  • Pure Dart-based implementation
    • works on all platforms supported by dart
  • Uses the official REST-API endpoints
  • Provides high-level classes to manage authentication and users
  • Supports multiple parallel Logins of different users
  • Supports automatic background refresh
  • Supports all login methods
  • Proivides low-level REST classes for direct API access (import firebase_auth_rest/rest.dart)

Installation

Simply add firebase_auth_rest to your pubspec.yaml and run pub get (or flutter pub get).

Usage

The libary consists of two primary classes - the FirebaseAuth and the FirebaseAccount. You can use the FirebaseAuth class to perform "global" API actions that are not directly tied to a logged in user - This are things like creating accounts and signing in a user, but also functions like resetting a password that a user has forgotten.

The sign in/up methods of FirebaseAuth will provide you with a FirebaseAccount. It holds the users authentication data, like an ID-Token, and can be used to perform various account related operations, like changing the users email address or getting the full user profile. It also automatically refreshes the users credentials shortly before timeout - allthough that can be disabled and done manually.

Thw following code is a simple example, which can be found in full length, including errorhandling, at https://pub.dev/packages/firebase_auth_rest/example. It loggs into firebase as anonymous user, prints credentials and account details and then proceeds to permanently delete the account.

// Create auth instance and sign up as anonymous user
final fbAuth = FirebaseAuth(Client(), "API-KEY");
final account = await fbAuth.signUpAnonymous();

// print credentials und user details
print("Local-ID: ${account.localId}");
final userInfo = await account.getDetails();
print("User-Info: $userInfo");

// delete and dispose the account
await account.delete();
account.dispose();

Documentation

The documentation is available at https://pub.dev/documentation/firebase_auth_rest/latest/. A full example can be found at https://pub.dev/packages/firebase_auth_rest/example.

Testing

If you intend to run the integration tests, you will have to create a firebase project with the authentication enabled. You must enable E-Mail and anonymous authentication and disable the E-Mail enumeration protection. Note: This is only required to run the integration tests. For a normal firebase project you should never disable E-Mail enumeration protection. Finally, you have to create a .env file with the FIREBASE_API_KEY from the project.

Alternatively you can use the firebase emulator for testing. In that case, you will have to set the FIREBASE_EMULATOR_HOST and FIREBASE_EMULATOR_PORT in the .env file as well.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案