+ All Categories
Home > Mobile > Firebase Auth Tutorial

Firebase Auth Tutorial

Date post: 11-Jan-2017
Category:
Upload: bukhori-aqid
View: 280 times
Download: 2 times
Share this document with a friend
25
Firebase Auth 101 Authentication using Firebase SDK
Transcript
Page 1: Firebase Auth Tutorial

Firebase Auth 101Authentication using Firebase SDK

Page 2: Firebase Auth Tutorial

+ +

++

github.com/aqidd

Bukhori Muhammad Aqid

Page 3: Firebase Auth Tutorial

+ +

++

+ +

++

Firebase Auth : Some Capabilitieshttps://firebase.google.com/docs/auth/

Page 4: Firebase Auth Tutorial

+ +

++

+ +

++

Firebase Auth : Key Capabilitieshttps://firebase.google.com/docs/auth/

● Firebase UI

provides a drop-in auth solution that handles the UI flows for signing in users with email addresses and passwords, Google

Sign-In, and Facebook Login.

● Email & Password Authentication

● Federated identity provider integration

● Custom Auth Integration

Connect your app's existing sign-in system to the Firebase Authentication SDK and gain access to Firebase Realtime Database

and other Firebase services.

● Anonymous Auth

Use Firebase features that require authentication without requiring users to sign in first by creating temporary anonymous

accounts. If the user later chooses to sign up, you can upgrade the anonymous account to a regular account, so the user can

continue where they left off.

Page 5: Firebase Auth Tutorial

+ +

++

+ +

++

Firebase Console : Create Projecthttps://console.firebase.google.com

Page 6: Firebase Auth Tutorial

+ +

++

+ +

++

Facebook Developer : Create Projecthttps://developers.facebook.com

Page 7: Firebase Auth Tutorial

+ +

++

Firebase Console : Enable Auth

https://console.firebase.google.com/

Page 8: Firebase Auth Tutorial

+ +

++

+ +

++

1. Create a Firebase project in the Firebase console, if you don't already have one. If you already have an

existing Google project associated with your mobile app, click Import Google Project. Otherwise, click Create

New Project.

2. Click Add Firebase to your Android app and follow the setup steps. If you're importing an existing Google

project, this may happen automatically and you can just download the config file.

3. When prompted, enter your app's package name. It's important to enter the package name your app is

using; this can only be set when you add an app to your Firebase project.

4. At the end, you'll download a google-services.json file. You can download this file again at any time.

5. If you haven't done so already, copy this into your project's module folder, typically app/.

Integrate Firebase into your Apphttps://firebase.google.com/docs/android/setup

Page 9: Firebase Auth Tutorial

+ +

++

+ +

++

● Add rules to your root-level build.gradle file, to include the google-services plugin

● Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the

file to enable the Gradle plugin

Add Firebase SDK

Page 10: Firebase Auth Tutorial

+ +

++

+ +

++

● Declare the FirebaseAuth and AuthStateListener objects.

● Initialize the FirebaseAuth instance and the AuthStateListener method so you can track whenever the user

signs in or out.

Integrate Firebase Authhttps://firebase.google.com/docs/auth/android/start/

Page 11: Firebase Auth Tutorial

+ +

++

+ +

++

● Attach the listener to your FirebaseAuth instance in the onStart() method and remove it on onStop().

You can also add the listener in onAttach() method & remove it on onDetach() if you’re using Fragment

Integrate Firebase Auth (2)https://firebase.google.com/docs/auth/android/start/

Page 12: Firebase Auth Tutorial

+ +

++

+ +

++

● Create a new account by passing the new user's email address and password to

createUserWithEmailAndPassword

If the new account was created, the user is also signed in, and the AuthStateListener runs the onAuthStateChanged

callback. In the callback, you can use the getCurrentUser method to get the user's account data.

Registering a Userhttps://firebase.google.com/docs/auth/android/password-auth

Page 13: Firebase Auth Tutorial

+ +

++

+ +

++

● When a user signs in to your app, pass the user's email address and password to

signInWithEmailAndPassword

If sign-in succeeded, the AuthStateListener runs the onAuthStateChanged callback. In the callback, you can use the

getCurrentUser method to get the user's account data.

Logging In a Userhttps://firebase.google.com/docs/auth/android/password-auth

Page 14: Firebase Auth Tutorial

+ +

++

+ +

++

● When a user signs in to your app, pass the user's email address to sendPasswordReset

If password reset succeeded, Firebase will send an email to your account for a password reset steps.

Forgot Password

Page 15: Firebase Auth Tutorial

+ +

++

Integrate Facebook Login to your App

Facebook Login

Page 16: Firebase Auth Tutorial

+ +

++

+ +

++

1. Add mavenCentral() to your Module-level /app/build.gradle before dependencies

2. Add the compile dependency with the latest version of the Facebook SDK in the build.gradle file

compile 'com.facebook.android:facebook-android-sdk:4.+'

3. Build your project. Import com.facebook.FacebookSdk into your app.

4. Initialize Facebook SDK before you can use it. Add a call to FacebookSdk.sdkInitialize from onCreate in your

Application class

FacebookSdk.sdkInitialize(getApplicationContext());

AppEventsLogger.activateApp(this);

5. add your Facebook App ID to your project's strings file and update your Android manifest

6. Add a meta-data element to the application element

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

Integrate Facebook SDK into your Apphttps://developers.facebook.com/docs/android/getting-started

Page 17: Firebase Auth Tutorial

+ +

++

+ +

++

Set your Native Platform data

Configure your Facebook Apphttps://developers.facebook.com/docs/android/getting-started

Page 18: Firebase Auth Tutorial

+ +

++

+ +

++

On OSX

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1

-binary | openssl base64

On Windows

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl

sha1 -binary | openssl base64

On Android Studio :

Getting your Key Hash Valuehttps://developers.facebook.com/docs/android/getting-started

Page 19: Firebase Auth Tutorial

+ +

++

+ +

++

Configure your Facebook Login Parameter

Configure your Facebook Apphttps://developers.facebook.com/docs/android/getting-started

Page 20: Firebase Auth Tutorial

+ +

++

+ +

++

● Create CallbackManager Instance

● Register CallbackManager onActivityResult()

Using Facebook Login Buttonhttps://developers.facebook.com/docs/facebook-login/android/v2.2

Page 21: Firebase Auth Tutorial

+ +

++

+ +

++

● Add Facebook Login Button to your XML File

● Customize the properties of Login button and register CallbackManager

Using Facebook Login Button (2)https://developers.facebook.com/docs/facebook-login/android/v2.2

Page 22: Firebase Auth Tutorial

+ +

++

+ +

++

● After a user successfully signs in, in the LoginButton's onSuccess callback method, get an access token for the

signed-in user, exchange it for a Firebase credential, and authenticate with Firebase using the Firebase credential

Integrate Facebook Login with Firebasehttps://firebase.google.com/docs/auth/android/facebook-login

Page 23: Firebase Auth Tutorial

+ +

++

Clone Sample Project at :

https://github.com/aqidd/firebase-auth-sample

Page 24: Firebase Auth Tutorial

+ +

++

Clone Complete Project at :

https://github.com/aqidd/firebase-auth-sample/tree/develop

Page 25: Firebase Auth Tutorial

Thank you. Let’s talk!

www.flipbox.co.id

021 739 6426 • 0818 0725 2399

[email protected]

+ +

++


Recommended