I am trying to integrate FB login with my html website. I am using FB Javascript SDK version 2.5. The pop-up opens and ask the users for the userid and password but donnot ask for permissions like email, public profile, location etc although i have given the required permissions in the scope param. Below is my code.
HTML code:
<div id="btnFBLogin"> <img style="width: 35%"
src="assets/img/icons/facebookloginbutton.png" />
</div>
Initializing FB Javascript SDK and gets initialized on document load :
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXX',
xfbml : true,
oauth : true,
version : 'v2.5'
});
};
//Load SDK
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Calling FB.login api:
$('#btnFBLogin').on('click',function(){
FB.login(function(response) {
console.log(JSON.stringify(response));
if (response.status === 'connected') {
// Logged into your app and Facebook.
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
});
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}, {scope: 'public_profile,email'});
});
The response object returned after login by FB.api('/me', function(response) gives only full name of the user logged in. It doesn't give me the email id although i have send it in the scope parameter.