firebase_auth_oauth 0.1.1+1 copy "firebase_auth_oauth: ^0.1.1+1" to clipboard
firebase_auth_oauth: ^0.1.1+1 copied to clipboard

discontinuedreplaced by: firebase_auth
outdated

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.

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  Future<void> performLogin(String provider, List<String> scopes,
      Map<String, String> parameters) async {
    try {
      await FirebaseAuthOAuth().openSignInFlow(provider, scopes, parameters);
    } on PlatformException catch (error) {
      /**
       * The plugin has the following error codes:
       * 1. FirebaseAuthError: FirebaseAuth related error
       * 2. PlatformError: An platform related error
       * 3. PluginError: An error from this plugin
       */
      debugPrint("${error.code}: ${error.message}");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: StreamBuilder(
              initialData: null,
              stream: FirebaseAuth.instance.onAuthStateChanged,
              builder:
                  (BuildContext context, AsyncSnapshot<FirebaseUser> snapshot) {
                return Column(
                  children: [
                    Center(
                      child: Text(
                          snapshot.data == null ? "Logged out" : "Logged In"),
                    ),
                    if (snapshot.data == null) ...[
                      RaisedButton(
                        onPressed: () async {
                          await performLogin(
                              "apple.com", ["email"], {"locale": "en"});
                        },
                        child: Text("Sign in By Apple"),
                      ),
                      RaisedButton(
                        onPressed: () async {
                          await performLogin(
                              "twitter.com", ["email"], {"lang": "en"});
                        },
                        child: Text("Sign in By Twitter"),
                      ),
                      RaisedButton(
                        onPressed: () async {
                          await performLogin(
                              "github.com", ["user:email"], {"lang": "en"});
                        },
                        child: Text("Sign in By Github"),
                      )
                    ],
                    if (snapshot.data != null)
                      RaisedButton(
                        onPressed: () async {
                          await FirebaseAuth.instance.signOut();
                        },
                        child: Text("Logout"),
                      )
                  ],
                );
              })),
    );
  }
}
86
likes
0
pub points
87%
popularity

Publisher

verified publisheramryousef.me

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.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

firebase_auth, firebase_auth_oauth_platform_interface, firebase_auth_oauth_web, firebase_core, flutter

More

Packages that depend on firebase_auth_oauth