0

I am using Parse for my app, and wanting to set up Parse's create user from facebook log-in. I am plently familiar with how to log-in a user with Facebook JS SDK, however, trying to use Parse's system is giving me an error. When the user clicks a button it should run the log-in function. The click function works, but when parse runs the FB.login, the facebook pop up goes up and then closes without doing anything. In the console I get the error: POST https://api.parse.com/1/users 400 (Bad Request). (Also, before the error I get FB.init has already been called - this could indicate a problem.)

Here is my JS:

<script type="text/javascript">     
    // Initialize the Parse object first.
    Parse.initialize("XXXXXXXXXXX", "UUUUUUUUUU");

    window.fbAsyncInit = function() {
        Parse.FacebookUtils.init({
            appId      : 'XXXXXXXXXXX', 
            status     : true, 
            cookie     : true, 
            xfbml      : true
        });
        $("#fbLogin").on("click", function(){
            Parse.FacebookUtils.logIn("email", {
            success: function(user) {
            // Handle successful login
            },
            error: function(user, error) {
            // Handle errors and cancellation
            }
            });
        });
    };
    (function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
    }(document));
    </script>

Im not using a channel file, because it looks like that is out of date since facebook documentation on it is deleted. I appreciate all help!

1 Answer 1

2

I have seen this error when I have a stale Facebook login or a stale Parse user login. Try logging out of Facebook and entering Parse.User.logOut(); into your javascript console, and then trying again.

Sign up to request clarification or add additional context in comments.

2 Comments

I know this comment is late due, but I still appreciate the attempt to help even after how long this was up answer-less! I ended up figuring it out, it was a problem with how Parse was interpreting everything and sending it to Facebook since I am using Phonegap. I had to use the regular FB.login(), grab the AuthData and then just log-in with Parse normally with Parse.FacebookUtils.logIn(facebookAuthData, ...); And then just check if the user exists or not before I decide whether to save their info or just redirect to home. Hope that helps someone in the future!
I was wondering what did you do to achieve that beforesave filter on the facebook login, all I can find is the Success and Error callbacks on Parse.FacebookUtils.logIn()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.