After a rather frustrating bout with Facebook OAuth 2, and having my Facebook Connect login break completely on my site (www.thegameeffect.com), I'm turning to the wise minds of StackOverflow in hope of some guidance.
Things were working rather nicely as of a 1-2 months ago, but recently I've been having problems. Basically, I have followed the steps according to the FB developers site, and hit several other help guides from here, such as this link: (http://stackoverflow.com/questions/8537007/facebook-cookie-and-oauth-2-0-changes) and have sadly not had any luck.
My FB.Init code looks like below:
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({ appId: '145290112183820', status: true, cookie: true, xfbml: true, channelUrl: 'http://www.thegameeffect.com/fbchannel.html' });
//, oauth:true
};
(function () {
// var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
// js = d.createElement('script'); js.id = id; js.async = true;
// js.src = "//connect.facebook.net/en_US/all.js";
// d.getElementsByTagName('head')[0].appendChild(js);
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js#xfbml=1';
document.getElementById('fb-root').appendChild(e);
} ());
</script>
I have tried all variations of this, with oauth:true included, the channelurl excluded, the self invoking function with the top part uncommented, and still all that happens when I try to log in is the auth window pops up briefly, and then disappears. The code that gets executed when you click on the FB icon in the top left of the header is below:
FB.login(function (response) {
if (response.session) {
// do server side work (this never gets hit)
}
});
Any suggestions?
So, after a bit more digging, and a lot of debugging, I finally found the solution. I was able to get the javascript side of things working thanks to manishekhawat, and the server side thanks to this awesome post:
http://amirrajan.net/Blog/facebook-oauth-authentication-and-iframe-apps
For anyone having problems with the new Facebook oAuth cookie in ASP.NET, this is an amazing tutorial!
Thanks again for the help today; I'm glad to finally have everything in working order.