Facebook registration page - Invalid 'client_id' when not logged into Facebook

懵懂的女人 提交于 2019-12-06 11:35:25

Check that the app whose ID you're using isn't restricted demographically (e.g. by age or country) and that it isn't still in sandbox mode.

If it is restricted or in sandbox mode, users who aren't logged in and who meet the restrictions applied (or for sandbox mode, are admins of the app) can't see the existence of the app or its details until they log in.

Just to confirm; I never actually fixed this properly. Instead I made a work around and was able to do a javascript check via the facebook sdk to see if the user was logged in or not when they first hit the page that has the facebook registration form.

I do an http redirect if they aren't logged in (or aren't authorised) and if they are logged in later in the page I call to init the facebook form.

window.fbAsyncInit = function() {
FB.init({
    appId      : xxxx, // App ID
    channelUrl : 'http:///xxxxx/fbchannel.php', 
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
});

// Additional initialization code here
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        // all ok!
        //var uid = response.authResponse.userID;
        //var accessToken = response.authResponse.accessToken;
    } else if (response.status === 'not_authorized') {
        window.location.href="create_account_with_facebook?authorizefirst";
    } else {
        window.location.href="create_account_with_facebook?loginfirst";
    }
});
};
// Load the SDK Asynchronously
(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));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!