GetLoginStatus does not shoot with a call from FB canvas

An attempt to authorize on a client site and an attempt to run inside the canvas. If I access directly my site http://mysite.com/ , everything works. If I try to run through canvas https://apps.facebook.com/myapp , it starts, but getLoginStatus does not start at all.

var curLoc = window.location; FB.init({ appId: 'xxxxxxxxxxxxxxx', // App ID channelUrl: curLoc.protocol + "//" + curLoc.hostname + ":" + curLoc.port + "/channel.html", cookie: true, // enable cookies to allow the server to access the session status: true, oauth: true, xfbml: true }); FB.getLoginStatus(function (response) { if (response.status === 'connected') { smloader.gameVariables.smUserid = response.authResponse.userID; facebook.isLoaded = true; } else { facebook.authUser(); } }, true); 

Sign in if necessary.

 function facebook.authUser() { FB.login(function (response) { if (response.authResponse) { smloader.gameVariables.smUserid = response.authResponse.userID; facebook.isLoaded = true; } else { facebook.authUser(); } }, { scope: 'email,publish_actions' }); 

}

Once Facebook.isLoaded is correct, I know that we are logged in and ready to continue. but he never goes directly to the canvas page.

I'm in sandbox mode, currently running via http, not https, since I don't

Any ideas?

+4
source share
1 answer

I came across the same pb, and here is how I fixed it:

Even if getLoginStatus () runs on your http web site, getLoginStatus () will not run at all inside canvas fb unless you provide a valid protected canvas URL ( https://yoursite.com/ )! This means that you need to run the application on an https server (port 443)
If you do not want to buy a certificate, you can create a self-signed certificate (see here http://greengeckodesign.com/blog/2013/06/15/creating-an-ssl-certificate-for-node-dot-js/ )

Hope this helps

+1
source

Source: https://habr.com/ru/post/1440721/


All Articles