搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.16

desktop_webview_auth

此套件透過 WebView 在桌面端啟用 Firebase OAuth

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
5.4萬
喜歡數
54
Pub 分數
120

安裝套件

flutter pub add desktop_webview_auth

套件介紹

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

一個 Flutter 套件,可在桌面平台(macOS、Windows、Linux)上使用 WebView 實現 Firebase OAuth 認證。它透過在應用程式內嵌入瀏覽器視窗,提供一種無縫處理 OAuth 流程的方式,讓使用者能使用 Firebase 登入,同時維持安全性與使用者體驗。此套件特別適用於需要在桌面環境中進行認證的應用程式,這些環境中的原生 OAuth 支援可能較為有限。它可直接與 Firebase Auth 整合,並支援 Android、iOS、Web 及桌面作業系統等多個平台。

適用情境

  • 使用 Firebase 進行桌面應用程式驗證
  • 跨平台桌面應用程式中的OAuth流程
  • 透過 WebView 在 macOS、Windows 和 Linux 上實現安全登入
  • 將 Firebase Auth 集成到桌面應用程式
  • 處理桌面環境中的 OAuth 重定向

主要特色

  • 支援桌面平台的 Firebase OAuth
  • 使用嵌入式網頁視圖進行驗證
  • 跨平台相容性
  • 安全的令牌處理
  • 與 Firebase Auth 的簡化整合
  • 自動處理 OAuth 重定向 URL

適合對象

  • 使用 Firebase 認證開發桌面應用程式的開發者
  • 在 macOS、Windows 或 Linux 上需要 OAuth 的應用
  • 需要在桌面端實現安全、原生體驗登入的項目
  • 針對多平台部署且具有一致驗證的團隊
  • 尋求可靠桌面OAuth解決方案的Flutter開發者

使用建議

  • 需要在 Firebase 控制台中進行正確的 OAuth 配置
  • 可能需要自定義 URL 方案來處理重定向
  • 僅限 Firebase Auth 集成
  • Webview 行為在不同桌面作業系統上可能略有差異
  • 不適用於僅限行動裝置的使用案例

原始 README

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

Desktop webview auth

Chat on Discord

This package enables Firebase OAuth on desktop platforms via webview

⚠️ Maintenance status: not actively maintained

This package was built to fill a gap: OAuth sign-in flows for Flutter desktop apps, at a time when the official Firebase solutions had no desktop support.

It still works, and for some use cases it remains the nicest desktop OAuth experience available — but it is not integrated with the wider FlutterFire ecosystem, and Invertase is no longer actively developing it. We will keep the repository public and accept the occasional community PR, but there is no guaranteed maintenance, no roadmap, and no support commitment. Issues may go unanswered.

It's kept public because it's still useful as-is, and because it's a solid starting point for anyone wanting to build a pure-Dart auth implementation. If you depend on it, please pin your version and be prepared to fork.

Supported providers:

  • Google
  • Facebook
  • Twitter

Installation

macOS setup

The recaptcha verification flow is done on the local server, and it requires that the app has the following in the Release.entitlements:

<key>com.apple.security.network.server</key>
<true/>
Linux setup

To display webview on Linux, WebKit2GTK development libraries are used, if you don't have it already installed:

Ubuntu:

apt install libwebkit2gtk-4.0-dev

Fedora:

dnf install webkit2gtk3-devel

Additionally, if Flutter is installed using snap, you might face issues compiling the app, to fix you would need to uninstall the snap version and install Flutter manually on Linux.

Windows setup

Make sure you are on latest stable channle of Flutter, and have installed the requirements as mentioned here.

Nothing extra is needed to get started on Windows.

Add dependency
flutter pub add desktop_webview_auth
Imports
import 'package:desktop_webview_auth/desktop_webview_auth.dart';
import 'package:desktop_webview_auth/google.dart';
import 'package:desktop_webview_auth/facebook.dart';
import 'package:desktop_webview_auth/twitter.dart';

Usage

  • Configure OAuth providers in firebase console
  • Create an instance of ProviderArgs
final googleSignInArgs = GoogleSignInArgs(
  clientId:
    '448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com',
  redirectUri:
    'https://react-native-firebase-testing.firebaseapp.com/__/auth/handler',
  scope: 'email',
)
  • call DesktopWebviewAuth.signIn
try {
    final result = await DesktopWebviewAuth.signIn(args);

    print(result?.accessToken);
    print(result?.tokenSecret);
} catch (err) {
    // something went wrong
}
  • create an instance of OAuthCredential and sign in
import 'package:firebase_auth/firebase_auth.dart';

final credential = GoogleAuthProvider.credential(accessToken: result.accessToken)

FirebaseAuth.instance.signInWithCredential(credential);

所屬分類

依賴

依賴清單 3 項

  • crypto^3.0.3
  • http^1.0.0
  • plugin_platform_interface^2.1.4

原始碼儲存庫

使用此套件的專案