Facebook Authentication - Cannot read property 'login' of undefined


#1

Hello,
Following all the steps from here:
[https://docs.ionic.io/services/auth/facebook-auth.html#logout](

https://docs.ionic.io/services/auth/facebook-auth.html#logout)

I got the error below on click > FACEBOOK LOGIN button.

Should I mention that I’m launching the app. in Chrome.

Many thanks in advance.

ionic.bundle.js:26799 TypeError: Cannot read property 'login' of undefined
    at ChildScope.$scope.onClickIonicFacebookAuth (controllers.js:168)
    at fn (eval at compile (ionic.bundle.js:27643), <anonymous>:4:263)
    at ionic.bundle.js:65429
    at ChildScope.$eval (ionic.bundle.js:30400)
    at ChildScope.$apply (ionic.bundle.js:30500)
    at HTMLButtonElement.<anonymous> (ionic.bundle.js:65428)
    at defaultHandlerWrapper (ionic.bundle.js:16792)
    at HTMLButtonElement.eventHandler (ionic.bundle.js:16780)
    at triggerMouseEvent (ionic.bundle.js:2953)
    at tapClick (ionic.bundle.js:2942)
    at HTMLDocument.tapTouchEnd (ionic.bundle.js:3069)

#2

The problem is that $ionicAuth is undefined and I really don’t know why.
Please see below.

angular.module('app.controllers', ['ionic.cloud'])
......
.controller('sHARECONFIGCtrl', ['$scope', function($scope, $ionicAuth, $ionicUser) {
    $scope.onClickIonicFacebookAuth = function () {
        $ionicAuth.login().then(function(){
            $state.go('menu.home');
        }, function(){
            $scope.error = 'Error logging in.';
        })
    }

}])

#3

I have solved this chaging the controller phrase
.controller(‘sHARECONFIGCtrl’, [’$scope’, function($scope, $ionicAuth, $ionicUser) ….
with:
.controller(‘sHARECONFIGCtrl’, [’$scope’,’$ionicAuth’,’$ionicUser’, function($scope, $ionicAuth, $ionicUser) {…

BUT:

I got a new error:

ionic.bundle.js:26799 Error: Authentication class is invalid or missing:undefined
    at e.login (ionic.cloud.min.js:6)
    at ChildScope.$scope.onClickIonicFacebookAuth (controllers.js:168)
    at fn (eval at compile (ionic.bundle.js:27643), <anonymous>:4:263)
    at ionic.bundle.js:65429
    at ChildScope.$eval (ionic.bundle.js:30400)
    at ChildScope.$apply (ionic.bundle.js:30500)
    at HTMLButtonElement.<anonymous> (ionic.bundle.js:65428)
    at defaultHandlerWrapper (ionic.bundle.js:16792)
    at HTMLButtonElement.eventHandler (ionic.bundle.js:16780)
    at triggerMouseEvent (ionic.bundle.js:2953)
    at tapClick (ionic.bundle.js:2942)
    at HTMLDocument.tapTouchEnd (ionic.bundle.js:3069)

#4

The error is here, on ionic.cloud.min.js

e.prototype.login = function(e, t, n) {
                var o = this;
                void 0 === n && (n = {}), "undefined" == typeof n.remember && (n.remember = !0), "undefined" == typeof n.inAppBrowserOptions && (n.inAppBrowserOptions = {}), "undefined" == typeof n.inAppBrowserOptions.location && (n.inAppBrowserOptions.location = !1), "undefined" == typeof n.inAppBrowserOptions.clearcache && (n.inAppBrowserOptions.clearcache = !0), "undefined" == typeof n.inAppBrowserOptions.clearsessioncache && (n.inAppBrowserOptions.clearsessioncache = !0);
                var r = this.authModules[e];
                if (!r) throw new Error("Authentication class is invalid or missing:" + r);
                return r.authenticate(t, n).then(function(e) {
                    return o.storeToken(n, e.token), o.userService.load().then(function() {
                        var t = o.userService.current();
                        return t.store(), e
                    })
                })