firebase_auth_oauth 0.1.0+3

  • Readme
  • Changelog
  • Example
  • Installing
  • new67

firebase_auth_oauth #

A Flutter plugin that makes it easy to perform OAuth sign in flows using FirebaseAuth. It also includes support for Sign in by Apple for Firebase. This plugin supports Android, iOS and Web. OAuth flows are performed by opening pop-up on top of the application to allow the user to authenticate or the native flow in the case of sign in by apple.

Usage #

You need to setup Firebase for your project first before using this plugin.

  • In your pubspec.yaml add
dependencies:
  flutter:
    sdk: flutter
  firebase_auth: ^0.15.3
  firebase_core: ^0.4.3+1
  firebase_auth_oauth: ^0.1.0
  • Then in your project just call

FirebaseUser user = await FirebaseAuthOAuth().openSignInFlow("A provider ID", [list of scopes], {custom parameters map});

// Sign-in by Apple example

FirebaseUser user = await FirebaseAuthOAuth()
          .openSignInFlow("apple.com", ["email"], {"locale": "en"});

Also Checkout the example Widget.

0.1.0+3 #

  • Updated example

0.1.0+2 #

  • Fix release builds on iOS

0.1.0+1 #

  • Fix builds on iOS

0.1.0 #

  • Initial release

example/lib/main.dart

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:firebase_auth_oauth/firebase_auth_oauth.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Future<void> performSignIn() async {
    try {
      await FirebaseAuthOAuth()
          .openSignInFlow("apple.com", ["email"], {"locale": "en"});
    } on PlatformException {
      debugPrint("error logging in");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            Center(
              child: Text('Running example'),
            ),
            Padding(
              padding: EdgeInsets.all(10),
              child: StreamBuilder(
                  initialData: null,
                  stream: FirebaseAuth.instance.onAuthStateChanged,
                  builder: (BuildContext context,
                      AsyncSnapshot<FirebaseUser> snapshot) {
                    return RaisedButton(
                      onPressed: () async {
                        if (snapshot.data != null) {
                          await FirebaseAuth.instance.signOut();
                        } else {
                          await performSignIn();
                        }
                      },
                      child: Text(snapshot.data != null ? "Logout" : "Login"),
                    );
                  }),
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  firebase_auth_oauth: ^0.1.0+3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:firebase_auth_oauth/firebase_auth_oauth.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
34
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
firebase_auth ^0.15.3 0.15.3+1
firebase_auth_oauth_platform_interface ^0.1.0 0.1.0
firebase_auth_oauth_web ^0.1.0+2 0.1.0+2
firebase_core ^0.4.3+1 0.4.3+2
flutter 0.0.0
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
firebase 7.2.0
firebase_auth_platform_interface 1.1.5
firebase_auth_web 0.1.1+4
firebase_core_platform_interface 1.0.2
firebase_core_web 0.1.1+2
flutter_web_plugins 0.0.0
http 0.12.0+4
http_parser 3.1.3
js 0.6.1+1
matcher 0.12.6
meta 1.1.8
path 1.6.4
pedantic 1.9.0
quiver 2.1.2+1
sky_engine 0.0.99
source_span 1.6.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test