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

套件詳情v0.3.0

google_sign_in_dartio

用 Dart 編寫的 Flutter 專案,支援 Google 登入,並同時支援行動與桌面環境。

AndroidiOSmacOS
近 30 天下載
9710
喜歡數
29
Pub 分數
150

安裝套件

flutter pub add google_sign_in_dartio

套件介紹

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

一個 Flutter 套件,使用純 Dart 實現 Google 登入,支援 Android、iOS 與 macOS。它提供跨平台的驗證解決方案,無需依賴原生程式碼,簡化了在行動與桌面環境中的整合。此套件專為尋求輕量級、統一方法進行 Google 驗證的開發者設計。

適用情境

  • 跨平台應用中的使用者驗證
  • 簡化行動裝置與桌面端的登入流程
  • 在Flutter應用程式中整合Google帳戶
  • 啟用無需原生依賴的安全登入
  • 支援多平台身分管理

主要特色

  • 純 Dart 實現
  • 跨平台支援(Android、iOS、macOS)
  • 無需原生程式碼
  • 輕量且易於整合
  • 內建的 OAuth2 權杖處理

適合對象

  • 針對多個平台的開發人員,使用共享的身份驗證邏輯
  • 專案避免使用平台特定的原生程式碼
  • 桌面和行動裝置上需要無縫 Google 登入的應用程式
  • 優先考慮跨平台程式碼一致性的團隊
  • 需要最少設定即可進行 Google 身份驗證的應用程式

使用建議

  • 僅限 Google 登入
  • 需要在 Google Cloud Console 中進行正確設定
  • 與平台特定的 SDK 相比,功能可能較少
  • 依賴互聯網連接進行驗證
  • 不適合用於複雜的OAuth工作流程,僅適用於基本登入

原始 README

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

google_sign_in_dartio

A Flutter package that implements Google Sign In in pure Dart. This package is compatible with google_sign_in plugin and works on all platforms Flutter supports but it's intended to be mainly used on Desktop.

Getting Started

Install and initialization
  1. Depend on it
    dependencies:
      google_sign_in: ^4.1.4
      google_sign_in_dartio: ^0.0.6
    
  2. Run flutter pub get
  3. Import
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
  4. Register the package
    import 'package:flutter/material.dart';
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
    void main() {
      if (isDesktop) {
        GoogleSignInDart.register(clientId: <clientId>);
      }
    
      runApp(MyApp());
    }
    
    Note: You might want to await for the register method to finish before calling any GoogleSignIn methods when your app starts.
Usage

You can use the normal GoogleSignIn methods.

final GoogleSignInAccount account = await GoogleSignIn().signIn();

Obtain a Client ID for your Desktop app

  1. Go to the Google Cloud Platform console and select you project
  2. Go to APIs & Service -> Credentials
  3. Create new credentials for your app by selecting CREATE CREDENTIALS and then OAuth client ID
  4. Select Other as Application type, give it a name (eg. macOS) and then click Create
Provide a code exchange endpoint

The user accessToken expires after about one hour, after witch you need to ask the user to login again. If you want to keep the user logged in, you need to deploy a oAuth code exchange endpoint. Once you have your endpoint you can register the package like this.

NOTE:

If you use this only for FirebaseAuth you don't need the code exchange since the token must be valid only when you use the signInWithCredentials method.

    import 'package:flutter/material.dart';
    import 'package:google_sign_in/google_sign_in.dart';
    import 'package:google_sign_in_dartio/google_sign_in_dartio.dart';
    
    void main() {
      if (isDesktop) {
        GoogleSignInDart.register(
            clientId: <clientId>, 
            exchangeEndpoint: <endpoint>,
        );
      }
    
      runApp(MyApp());
    }
NOTE:

GoogleSignInTokenData exposes serverAuthCode field that should contain the exchange code from the authorization request. This will always be null when using this package because we already allow you to provide a code exchange endpoint witch exposes the code and code verifier in a trusted environment and encourages not to do the code exchange on the client.

See instruction on how to deploy a code exchange endpoint.

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。