GithubHelp home page GithubHelp logo

tasseri / flutter_desktop_webview_auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from invertase/flutter_desktop_webview_auth

0.0 0.0 0.0 184 KB

WebView OAuth flows for desktop flutter apps

License: Apache License 2.0

Ruby 2.77% C++ 36.15% C 2.49% Objective-C 0.68% Kotlin 1.13% Dart 33.30% Swift 5.84% CMake 17.64%

flutter_desktop_webview_auth's Introduction

Desktop webview auth

Chat on Discord

This package enables Firebase OAuth on desktop platforms via webview

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);

flutter_desktop_webview_auth's People

Contributors

lesnitsky avatar pr-mais avatar lyokone avatar salakar avatar ioayman avatar britannio avatar rodydavis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.