Skip to content

Instantly share code, notes, and snippets.

@edpittol
Created September 14, 2014 04:49
Show Gist options
  • Save edpittol/3492b086affcc5100708 to your computer and use it in GitHub Desktop.
Save edpittol/3492b086affcc5100708 to your computer and use it in GitHub Desktop.
Parse Facebook Login
// Initialize the Facebook SDK with Parse as described at
// https://parse.com/docs/js_guide#fbusers
window.fbAsyncInit = function() {
// init the FB JS SDK
Parse.FacebookUtils.init({
appId : '289802934544559', // Facebook App ID
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v1.0' // use version 1
});
// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
FB.api('/me', function(response) {
console.log(response);
});
}
});
$("#fb-login").on("click", function(){
Parse.FacebookUtils.logIn("email,public_profile", {
success: function(user) {
console.log("Success");
console.log(user);
},
error: function(user, error) {
console.log("Error");
console.log(error);
console.log(user);
}
});
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment