Getting ionicFacebookAuth to work


#1

Hello

I am trying to get Facebook login working. I think I am almost there but must be missing a step.

I have a link to #/app/facebook to start the process

Inside app.js I have:

.state('app.facebook', {
	url: "/facebook",
  	views: {
		'menuContent': {			
	 		controller: 'facebook'
		}
  	}, 	
})

Within app.js I also have …

angular.module('starter', ['ionic', 'starter.controllers', 'ionic.cloud'])

And …

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider, $ionicCloudProvider) {

	$ionicCloudProvider.init({
	  "core": {
	    "app_id": "my-facebook-app-id-is-here"
	  },
	  "auth": {
	    "facebook": {
	      "scope": ["email", "public_profile"]
	    }
	  }
	});

When I click the link I am taken to Facebook, I see my logo, I am asked to confirm that I want to proceed. I click OK.

I am returned back to my app and I see an alert saying … “FAIL: Error: BAD REQUEST”

Inside my controller.js file I have:

.controller('facebook', function($location, $scope, $ionicFacebookAuth, $ionicUser) {

	$ionicFacebookAuth.login()
		.then(function () {
			alert("GOOD");
			$scope.userData = $ionicUser.social.facebook.data;
			$location.path('/app/profile');
	    },function (fail) {
			alert("FAIL: " + fail);	    
			$scope.userData = $ionicUser.social.facebook.data;	      
			$location.path('/app/profile');			
	    }
	);
	
})

I have followed the instructions on http://docs.ionic.io/services/auth/facebook-native.html for setting up the app and have https://api.ionic.io/auth/integrations/facebook as the OAuth redirect URI.

Can anybody give me any tips?

Thank you :slight_smile:


#2

Did you ever solve this I am having the same issue.
It fails sileintly and my console.log(“good”) never fires.


#3

I gave up using the Ionic Package tool. Instead I run “ionic build ios”, open it in Xcode and then put it onto my phone. The Facebook integration then seems to work well.