Code Monkey home page Code Monkey logo

firebase_auth_ui's Introduction

firebase_auth_ui

Flutter plugin of Firebase UI which allows to add login/sign-up quickly.

NOTE: This plugin is under development. Please provide Feedback and Pull Requests in order to have your feature(s) integrated.

Screenshot

Usage

Import

import 'package:firebase_auth_ui/firebase_auth_ui.dart';
import 'package:firebase_auth_ui/providers.dart';

Use of the plugin

Present the auth screen
FirebaseAuthUi.instance()
        .launchAuth(
          [
            AuthProvider.email(), // Login/Sign up with Email and password
            AuthProvider.google(), // Login with Google
            AuthProvider.facebook(), // Login with Facebook
	    AuthProvider.twitter(), // Login with Twitter
	    AuthProvider.phone(), // Login with Phone number
          ],
          tosUrl: "https://my-terms-url", // Optional
          privacyPolicyUrl: "https://my-privacy-policy", // Optional,
        )
        .then((firebaseUser) =>
            print("Logged in user is ${firebaseUser.displayName}"))
        .catchError((error) => print("Error $error"));
Logout
void logout() async {
	final result = await FirebaseAuthUi.instance().logout();
	// ...
}
Delete
void delete() async {
	final result = await FirebaseAuthUi.instance().delete();
	// ...
}

Plugin returns FirebaseUser with following details:

Field Description
uid UID of authenticated user
displayName Display name of user
email Email of user
phoneNumber Phone number of user
photoUri URI of user's photo
providerId Indicates through which provider user was authenticated.
isNewUser Indicates if user is new
metaData Object of MetaData

MetaData

Field Description
creationTimestamp Timestamp of user's creation
lastSignInTimestamp Timestamp of user's last sign in

Notes:

  • Above details may be null depending on the provider user used to sign and user's privacy settings on respective provider.
  • creationTimestamp seems to return wrong value sometimes on Android.

If you want to have full FirebaseUser object then please add firebase_auth dependency. You can then use FirebaseAuth.instance.currentUser().

Configuration

Create a project on Firebase console and add Android and iOS platform in Settings > Your apps

  • Open the Authentication section and then navigate to Sign in method. Please enable Email/Password, Google, Facebook, Twitter and Phone method depending on your need and click save.
  • Navigate back to Settings > Your apps
  • Download "google-services.json" for Android
  • Download "GoogleService-Info.plist"for iOS

Android

Open project's build.gradle ([flutter_project]/android/build.gradle) and add following in dependencies{ ... }:

classpath 'com.google.gms:google-services:4.3.2'

Open app module's build.gradle ([flutter_project]/android/app/build.gradle) and add following at the end of file, i.e as a last line:

apply plugin: 'com.google.gms.google-services'

Copy the downloaded google-services.json in [flutter_project]/android/app directory.

iOS

Copy the downloaded GoogleService-Info.plist in [[flutter_project]/ios/Runner directory.

Additional setup for Google, Facebook, Twitter and Phone sign-in

Google

Android

No additional setup required.

iOS

  • Open the GoogleService-Info.plist and copy REVERSED_CLIENT_ID. It should look like com.googleusercontent.apps.[APP_ID-somevalue]
  • Now open "Info.plist" ([flutter_project]/ios/Runner and paste following by replacing [REVERSED_CLIENT_ID] with yours copied in above step:
<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>[REVERSED_CLIENT_ID]</string>
			</array>
		</dict>
	</array>

Facebook

Android

Add following lines in strings.xml [flutter_project]/android/app/src/main/res/values

<string name="facebook_application_id" translatable="false">[YOUR_FACEBOOK_APP_ID]</string>
<string name="facebook_login_protocol_scheme" translatable="false">fb[YOUR_FACEBOOK_APP_ID]</string>

iOS

  • Add fbFACEBOOK_APP_ID as a URL scheme Open open Info.plist ([flutter_project]/ios/Runner and paste following by replacing [YOUR_FACEBOOK_APP_ID] with yours:
<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>fb[YOUR_FACEBOOK_APP_ID]</string>
			</array>
		</dict>
	</array>

NOTE: If you have configured Google sign-in by following above steps, you already have CFBundleURLSchemes key defined with [REVERSE_CLIENT_ID]. In that case, just add

<string>fb[YOUR_FACEBOOK_APP_ID]</string>

below [REVERSE_CLIENT_ID]

  • Add facebook app id and app's name in Info.plist
<key>FacebookAppID</key>
	<string>[YOUR_FACEBOOK_APP_ID]</string>
	<key>FacebookDisplayName</key>
	<string>[YOUR_FACEBOOOK_APP_NAME]</string>

Twitter

Android

Add following lines in strings.xml [flutter_project]/android/app/src/main/res/values

<string name="twitter_consumer_key" translatable="false">[YOUR_CONSUMER_KEY]</string>
<string name="twitter_consumer_secret" translatable="false">fb[YOUR_CONSUMER_SECRET]</string>

iOS

If you have already configured Google sign-in for iOS following above steps, then you don't need to do anything else. If not, please follow the exact same step.

Phone number

Android

No additional setup required.

iOS

If you have already configured Google sign-in for iOS following above steps, then you don't need to do anything else. If not, please follow the exact same step.

Customization

Add logo

Rename your icon to auth_ui_logo.png then follow below steps:

Android
  • Place the png file in [flutter_project]/android/app/src/main/res/drawable
iOS
  • Create an imageset with auth_ui_logo and place the png inside it. For creating the imageset, you can open the iOS project in XCode and then drag and drop the png image in Assets.

Android specific

  • Actionbar title: Define your app's name in strings.xml and that'll appear as title in action bar.
  • Actionbar and status bar color: Add following in your colors.xml [flutter_project]/android/app/src/main/res/values
<color name="colorPrimary">#[ACTIONBAR_COLOR]</color>
<color name="colorPrimaryDark">#[STATUSBAR_COLOR]</color>

Note: If you don't have colors.xml, please create one.

Misc

  • The order of login buttons depends on the sequence of AuthProviders you passed in launchAuth(). For example if you have Email, Google and Facebook auth configured and would like the Facebook to appear first, you can simply pass the AuthProvider.facebook() as first element in the providers list.

firebase_auth_ui's People

Contributors

fdietze avatar sam0829 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

firebase_auth_ui's Issues

How to stay logged in?

From my understanding, logging in is only possible via launchAuth, which in turn takes forever to do its job even if the user signed in previously. Is there a way to store the authentication data until logout() is called? I can't find any api tokens exposed by this thing.

Facebook Login Error

W/Facebook Builder(30921): Facebook provider configured for Chrome Custom Tabs. I/BiChannelGoogleApi(30921): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzao@a145a65 W/DynamiteModule(30921): Local module descriptor class for com.google.firebase.auth not found. I/FirebaseAuth(30921): [FirebaseAuth:] Preparing to create service connection to gms implementation

"ui_flow" title in actionbar

Hi, when I launch the login/register process using
FirebaseAuthUi.instance()
.launchAuth
the first page that appears lets choose the login method (email, facebook etc) , the title in the action bar is "ui_flow" can that be changed?
Also, you have done a wonderful job with this. It is helping mw a lot
Thanks

Unable to start sign-in page on Web

Hello - thanks you for sharing the hard work you've done in this library. I wanted to help by reporting that when trying to open the sign in module in Flutter Web, I get the following error:

Error MissingPluginException(No implementation found for method launchFlow on channel firebase_auth_ui)

I'm using the FirebaseAuthUi.instance().launchAuth([ method as shared in the examples. I see that uses some sort of reflection (I'm not a Dart expert).

Is this a valid defect? If so, how can I help fix it?
Also, is there a workaround? How can I manually trigger the login screen (launchFlow)?

Thanks so much in advance.

delete user throws native exception

Hello, I am getting "java.lang.IllegalStateException: Reply already submitted" when trying to call the delete function on the user.
Could you update a bit this library? It is very useful to many of us that have used it.
Thank you

Feature: Phone Authentication

Thanks for this amazing package, it really reduces the authentication burden!

It would be really great if the authentication method by phone number would be added. For me it is still the best way to integrate contacts in my app.

Happy to hear from you!

App Crashes on show auth UI

gradle:
android compileSdkVersion 29
minSdkVersion 18
targetSdkVersion 29
multiDexEnabled true

flutter doctor:
Flutter (Channel master, 1.24.0-8.0.pre.149, on Linux, locale es_AR.UTF-8)
• Flutter version 1.24.0-8.0.pre.149 at /home/xxx/snap/flutter/common/flutter
• Framework revision 8e7748e74c (hace 3 semanas), 2020-11-08 20:32:04 -0800
• Engine revision 0f7cdca65f
• Dart version 2.12.0 (build 2.12.0-27.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /home/xxx/Android/Sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /home/xxx/apps/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

pubspec:
flutter sdk: ">=2.7.0 <3.0.0"

dependencies:

firebase_auth_ui: ^1.0.1
firebase_auth: ^0.18.0+1

phone
Sony Xperia XA1 Plus
Android 8.0 (SDK 26)

stacktrace:

java.lang.RuntimeException:
at android.view.DisplayListCanvas.throwIfCannotDraw (DisplayListCanvas.java:229)
at android.view.RecordingCanvas.drawBitmap (RecordingCanvas.java:97)
at android.graphics.drawable.BitmapDrawable.draw (BitmapDrawable.java:529)
at android.widget.ImageView.onDraw (ImageView.java:1367)
at android.view.View.draw (View.java:19380)
at android.view.View.updateDisplayListIfDirty (View.java:18287)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw (ConstraintLayout.java)
at android.view.View.updateDisplayListIfDirty (View.java:18275)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at android.view.View.updateDisplayListIfDirty (View.java:18275)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at android.view.View.updateDisplayListIfDirty (View.java:18275)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at android.view.View.updateDisplayListIfDirty (View.java:18275)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at android.view.View.updateDisplayListIfDirty (View.java:18275)
at android.view.View.draw (View.java:19092)
at android.view.ViewGroup.drawChild (ViewGroup.java:4344)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:4130)
at com.android.internal.policy.DecorView.dispatchDraw (DecorView.java:831)
at android.view.View.draw (View.java:19392)
at com.android.internal.policy.DecorView.draw (DecorView.java:817)
at android.view.View.updateDisplayListIfDirty (View.java:18287)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:643)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:649)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:757)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3380)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:3182)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2703)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1602)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7407)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:948)
at android.view.Choreographer.doCallbacks (Choreographer.java:750)
at android.view.Choreographer.doFrame (Choreographer.java:682)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:934)
at android.os.Handler.handleCallback (Handler.java:869)
at android.os.Handler.dispatchMessage (Handler.java:101)
at android.os.Looper.loop (Looper.java:206)
at android.app.ActivityThread.main (ActivityThread.java:6749)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:845)

new user sign up

Hi,
great package.
How can I know if this is a new user (sign up)? So I can insert him in firestore.
thanks

Cannot localize UI on iOS

Thank you for great plugin.
I want to display UI in Japanese but localize in Japanese is not work only on iOS.
Is there a option to localize on iOS?

features

Hi,
how about theses features?

  1. deleting user?
  2. tos and privacy policy (none, one or both), now if I only want one the other doesn't show
  3. when login via facebook, it doesn't show choice between accounts, like google did
  4. how can I change the languages?

thanks

Make the UI customizable

I don't know if this is already possible, but I would like to be able to customize the UI. Thanks

CocoaPods could not find compatible versions for pod "firebase_auth_ui":

Hi, I'm having some trouble launching the app on iPhone.
It gives me this error:

[!] CocoaPods could not find compatible versions for pod "firebase_auth_ui":
  In Podfile:
    firebase_auth_ui (from `.symlinks/plugins/firebase_auth_ui/ios`)

Specs satisfying the `firebase_auth_ui (from `.symlinks/plugins/firebase_auth_ui/ios`)` dependency were found, but they required a higher minimum deployment target.

and also :
Error output from CocoaPods:

[!] Automatically assigning platform `iOS` with version `8.1` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 11 Pro Max.

Can you give any help on this?

Error after adding the firebase_auth_ui dependence

Hello!

Thank you for the module!

Do you have any idea what is the reason for these errors even if I don't call any auth methods?

Launching lib\main.dart on AOSP on IA Emulator in debug mode...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
I/alatycalculato( 3195): Background concurrent copying GC freed 19514(1046KB) AllocSpace objects, 10(488KB) LOS objects, 49% free, 2MB/5MB, paused 1.187ms total 223.763ms
I/alatycalculato( 3195): Background concurrent copying GC freed 13864(1046KB) AllocSpace objects, 11(844KB) LOS objects, 49% free, 3MB/7MB, paused 4.201ms total 378ms
I/Choreographer( 3195): Skipped 238 frames! The application may be doing too much work on its main thread.
D/EGL_emulation( 3195): eglMakeCurrent: 0xec0499e0: ver 2 0 (tinfo 0xd15c0670)
I/OpenGLRenderer( 3195): Davey! duration=4493ms; Flags=1, IntendedVsync=109762932330284, Vsync=109766898996792, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=109766903257920, AnimationStart=109766903330620, PerformTraversalsStart=109766904922820, DrawStart=109766935093720, SyncQueued=109766938012320, SyncStart=109766948236420, IssueDrawCommandsStart=109766949191920, SwapBuffers=109767236805920, FrameCompleted=109767435603020, DequeueBufferDuration=58181000, QueueBufferDuration=1424000,
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
D/EGL_emulation( 3195): eglMakeCurrent: 0xebf87520: ver 2 0 (tinfo 0xd561fb90)
D/eglCodecCommon( 3195): setVertexArrayObject: set vao to 0 (0) 1 0
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}
E/GraphResponse( 3195): {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Cannot query users by their username (CHANGE-ME)}

Auth Management UI also?

Love the idea of this plugin.

Could we have a UI for managing the auth? Eg signout and deletion of user from app?

Twitter configuration is incorrect

The Twitter Configuration looks incorrect and incomplete.

  • fb looks like a copy/paste error.
  • it says that you really don't need to anything for iOS, but I had to do a few things, like add twitter and twitterauth to LSApplicationQueriesSchemes, and configure the callback handler to be twitterkit-<consumer-key>://

Open any auth flow directly without showing default screen

How can I implement any auth flow without showing default providers list screen as we can do in native sdk's?
eg. In iOS/Android native, we have the option to launch screen which provides buttons for multiple auth or we can also open any specific auth directly without showing auth providers list.

Need Sign In Apple Urgently

Dear @sam0829 please make for sign in by apple, because my application rejection several times by apple cause didn't have apple sign in.

thank you very much

The plugin `firebase_auth_ui` uses a deprecated version of the Android embedding.

Hi,
This is my first time working on a flutter app so i am sorry if this is a stupid question but please explain where am I going wrong. I have purchased a template app and since the first time trying to run it (no modifications) I see the following warning in RED (the app still runs):

The plugin firebase_auth_ui uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Following the bread crumbs have brought me here. Can you please let me know if this is something you can fix and update the package on pub.get or is there something I can do to to get rid of the error? I am worried of the red warning and that even if the app runs now if might not run in the future.

Thank you for your time to look into this and aswer.

Doesn't support latest Firebase in iOS

This compiles

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.5.0+1
  firebase_auth: ^0.18.0+2

This doesn't

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.5.0+1
  firebase_auth: ^0.18.0+2
  firebase_auth_ui: 1.0.1

The error is:

In file included from
    /Users/will/repos/loveblocks-labs/flutter_android_ios/flutter_android_ios/ios/Pods/FirebaseCoreDiagnostics/Firebase/CoreDiagnostics/FIR
    CDLibrary/FIRCoreDiagnostics.m:24:
    /Users/will/repos/loveblocks-labs/flutter_android_ios/flutter_android_ios/ios/Pods/FirebaseCoreDiagnostics/GoogleUtilities/Logger/Priva
    te/GULLogger.h:22:9: fatal error: 'GoogleUtilities/GULLoggerLevel.h' file not found
    #import <GoogleUtilities/GULLoggerLevel.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.

The packages used in this blog post are too old. I'm now following a promising guide that has fewer, generic dependencies.

It looks like that will work but I love this Library so I'm hoping to come back to it someday and rip out the workaround code. Cheers mate!

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.