Hi everyone.. Over the past week we have received a lot of reports related to Facebook Connect within Dynamic Login and the feature no longer working/JavaScript errors appearing. Facebook changed some of their code and we have been playing catch up…
The JavaScript Error:
OAuth2 specification states that 'perms' should now be called 'scope'. Please update.
[Break On This Error] FB.provide('',{getLoginStatus:function...signed_request,code'});return a;}}});
You will receive this error if you are running on 04.00 or 04.10 and you need to upgrade to the patch: 04.10.20 that is being released this afternoon or tomorrow morning at the latest.
What was changed / what if you want to modify it without the new install file?
All of the code changes necessary were directly in the ASCX file, so worst case scenario is that you copy/paste these changes directly into the module user control file. What do you change?
- response.session should be changed to response.authResponse
auth.sessionChange
is should be replaced with auth.authResponseChange
- perms should be changed to scope
Within the file called DesktopModules\Dynamic Login\DynamicLogin.ascx (you can modify the file in notepad) the updated source code should be:
Existing Facebook Script:
<script>
var DEBUG=false;
window.fbAsyncInit = function()
{
FB.Event.subscribe('auth.statusChange', onFacebookStatusChange);
FB.init({
appId : '',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(onFacebookInitialLoginStatus);
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function facebookLogin()
{
FB.login(onFacebookLoginStatus, {perms:''});
}
/*
* Callback function for FB.getLoginStatus
*/
function onFacebookInitialLoginStatus(response)
{
if (DEBUG)
{
alert("onFacebookLoginStatus(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
}
if (response.status=="connected" && response.session)
{
// At this stage, user is logged in.
// For this example, I am logging out the user if the user is already logged in.
//FB.logout();
// alert('Does this fire first or 2nd');
}
else
{
// User if not logged in.
}
}
/*
* Callback function for 'auth.statusChange' event.
*/
function onFacebookStatusChange(response)
{
if (DEBUG)
{
alert("onFacebookStatusChange(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
}
}
/*
* Callback function for FB.login
*/
function onFacebookLoginStatus(response)
{
if (DEBUG)
{
alert("onFacebookLoginStatus(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.session
+" \nresponse.perms="+response.perms);
}
if (response.status=="connected" && response.session)
{
//alert("You are all set... We now need to get the access token and do a JavaScript refresh.");
Javascript:__doPostBack('callback','')
}
else
{
alert("Please login to enjoy this application.");
}
}
</script>
New Facebook Script:
<script>
var DEBUG=false;
window.fbAsyncInit = function()
{
FB.Event.subscribe('auth.statusChange', onFacebookStatusChange);
FB.init({
appId : '',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(onFacebookInitialLoginStatus);
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function facebookLogin()
{
FB.login(onFacebookLoginStatus, {scope:''});
}
/*
* Callback function for FB.getLoginStatus
*/
function onFacebookInitialLoginStatus(response)
{
if (DEBUG)
{
alert("onFacebookLoginStatus(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.authResponse.accessToken
+" \nresponse.scope="+response.scope);
}
if (response.status=="connected" && response.authResponse.accessToken)
{
// At this stage, user is logged in.
// For this example, I am logging out the user if the user is already logged in.
//FB.logout();
// alert('Does this fire first or 2nd');
}
else
{
// User if not logged in.
}
}
/*
* Callback function for 'auth.statusChange' event.
*/
function onFacebookStatusChange(response)
{
if (DEBUG)
{
alert("onFacebookStatusChange(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.authResponse.accessToken
+" \nresponse.scope="+response.scope);
}
}
/*
* Callback function for FB.login
*/
function onFacebookLoginStatus(response)
{
if (DEBUG)
{
alert("onFacebookLoginStatus(), "
+ "\nresponse.status="+response.status
+" \nresponse.session="+response.authResponse.accessToken
+" \nresponse.scope="+response.scope);
}
if (response.status=="connected" && response.authResponse)
{
//alert("You are all set... We now need to get the access token and do a JavaScript refresh.");
Javascript:__doPostBack('callback','')
}
else
{
alert("Please login to enjoy this application.");
}
}
</script>
Thanks!
-Chad