Search code examples
javascriptangularjscordovangcordova

Login with $cordovaOauth issue


function facebookLogin() {
            $cordovaOauth.facebook("948645908488914", ["email"]).then(function (result) {
            displayData($http, result.access_token);
        }, function (error) {
            alert("Error: " + error);
        });
    }

I'm not certain what the email value should be. Should it be the user's email address from witch the token should be obtained from ?

I am receiving the following error:

TypeError: Cannot read property 'hasOwnProperty' of undefined
    at Object.facebook (local://simulator/js/ng-cordova.min.js:24:6458)
    at facebookLogin (local://simulator/js/app/controllers/ng-controllers-all.js:47:23)
    at m.$scope.login (local://simulator/js/app/controllers/ng-controllers-all.js:43:9)
    at fn (eval at <anonymous> (local://simulator/js/angular.min.js:210:400), <anonymous>:2:206)
    at local://simulator/js/ionic-angular.min.js:20:5713
    at m.$eval (local://simulator/js/angular.min.js:134:83)
    at m.$apply (local://simulator/js/angular.min.js:134:309)
    at HTMLButtonElement.<anonymous> (local://simulator/js/ionic-angular.min.js:20:5695)
    at HTMLButtonElement.n.event.dispatch (local://simulator/js/jquery-2.1.4.min.js:3:6466)
    at HTMLButtonElement.r.handle (local://simulator/js/jquery-2.1.4.min.js:3:3241)(anonymous function) @ angular.min.js:107

Solution

  • email is the permission that you are asking for, You pass the permissions like:

    $cordovaOauth.facebook("APP_ID", ['public_profile','user_friends','email','user_groups','user_likes']).then(function(result) {
    // Code
    

    the problem I guess is that you are not testing on a device.