Book Image

Ionic Cookbook

By : Hoc Phan
Book Image

Ionic Cookbook

By: Hoc Phan

Overview of this book

Table of Contents (18 chapters)
Ionic Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating an Ionic social authentication project for Facebook using $firebaseAuth


So far, you have been just configuring the apps. This recipe will explain how easy it is to write the code to authenticate a user via Facebook, Twitter, or Google. You will go through an example app to set up a login button. The user will click on login to authenticate via his or her social network. Then, the app will display the basic profile information, including the user's picture. Finally, the user can click on logout to end the session.

Getting ready

The only thing that you need here is the Ionic CLI to perform the steps.

How to do it...

The following instructions are used to code for the Facebook authentication:

  1. Create a blank Ionic app (for example, SocialAuth), as follows:

    $ ionic start SocialAuth blank
    
  2. Go to the project folder:

    $ cd SocialAuth
    
  3. For authentication to work on a physical device, it will need two Cordova plugins, InAppBrowser and Cookies. The reason is that the authentication popup window will...