搜索插件、代码仓与 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

源码仓库

使用此插件的项目