javascriptfacebookapicordovangcordova

Login with Facebook using $cordovaOauth


I need to clear some doubts here regarding this ngCordova plugin

Lets go step by step

1st doubt:

When registering your application with various service providers such as Facebook or Google, it is very important to use http://localhost/callback as the callback / redirect uri. The Oauth module depends on this in order to complete the browser flow.

what they mean with the redirect call back ? it is like the route where the app goes after the login ? and where should I put that ?

2nd doubt:

module.controller('MyCtrl', function($scope, $cordovaOauth) {
    $scope.facebookLogin = function() {
        $cordovaOauth.facebook("CLIENT_ID_HERE", ["email"]).then(function(res) {
            // res
        }, function(err) {
            // err
        });
    }
});

what is the CLIENT_ID ? is the Facebook App ID ? or what ? what should I do withe the array ['email'] ? should I change that to something else ?


Solution

  • To use any API, including Facebook, you need to first log into the provider's dashboard and register your application.

    In this case, you would probably go to developers.facebook.com and register. When you've done this you'll be given a client id to use within your application.

    You're not done yet though. In the provider dashboard, you need to add http://localhost/callback as your OAuth redirect URI. You're doing this because ngCordova is set up to listen to that URL. When it's found, it knows to close the login flow.

    As for scope values, I suggest you read the Facebook documentation for a list of values and what they do.

    Regards,