Facebook Authentication

Ionic Cloud has been deprecated. To continue using Ionic services, migrate to Ionic Pro before Jan. 31, 2018.


Native Login

This is the documentation for implementing 3-legged authentication with the InAppBrowser plugin. For Native login, proceed to Facebook Native.

Create a Facebook App

The first step in setting up your Facebook authentication integration is to create an app on Facebook.

App ID & Secret

Now that you’ve got an app setup, you need to let us know about the App ID and App Secret. Both can be found on your Facebook app dashboard.

App Implementation


Plugin Installation

The InAppBrowser plugin is used to login your users with Facebook authentication.

$ cordova plugin add cordova-plugin-inappbrowser --save

Injecting Auth and User

Import Auth and User from the Cloud Client and specify them as dependencies in your component constructor.

  • auth is a service that deals with user authentication.
  • user is a reference to the current user, whether that user is anonymous or authenticated.
import { Component } from '@angular/core';
import { Auth, User } from '@ionic/cloud-angular';

@Component( ... )
export class LoginPage {
  constructor(public auth: Auth, public user: User) {

Specify ionic.cloud as a dependency for your module. This gives you access to $ionicAuth and $ionicUser.

  • $ionicAuth is a service that deals with user authentication.
  • $ionicUser is a reference to the current user, whether that user is anonymous or authenticated.
angular.module('myapp.controllers', ['ionic.cloud'])

.controller('MyCtrl', function($scope, $ionicAuth, $ionicUser) {


this.auth.login('facebook').then( ... );
$ionicAuth.login('facebook').then( ... );


Logging out clears the current user context.


Social Data

We store social data in user.social.facebook. Unlike your custom data which uses user.get() and user.set(), user.social.facebook is just an object with the following properties.

uid Facebook user ID
data Facebook data object
data.profile_picture Facebook profile picture
data.email Facebook email
data.full_name The user’s full name
data.raw_data The data object straight from Facebook


const full_name = this.user.social.facebook.data.full_name;
const profile_picture = this.user.social.facebook.data.profile_picture;
const facebook_raw_data = this.user.social.facebook.data.raw_data;
var full_name = $ionicUser.social.facebook.data.full_name
var profile_picture = $ionicUser.social.facebook.data.profile_picture
var facebook_raw_data = $ionicUser.social.facebook.data.raw_data;