简体   繁体   中英

Parse.com Facebook Log-In User

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM