Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save esperancaJS/3c4f24f928e5fd03863f5e6ba54cb3c1 to your computer and use it in GitHub Desktop.
Save esperancaJS/3c4f24f928e5fd03863f5e6ba54cb3c1 to your computer and use it in GitHub Desktop.
this.FbLogin = function(){
FB.login(function(response) {
console.log('login response');
console.log(response);
if(response.status === 'connected'){
FB.api('/me/permissions', function(response) {
console.log(response);
if(response.data[1].status !== 'granted'){ //email
retryToLogin();
}
});
}
// handle the response
}, {scope: 'public_profile,email', auth_type: 'rerequest'});
}
function retryToLogin(){
alert("We really need your email :s");
FB.logout(function(response) {
FB.login(function(response) {
if(response.status === 'connected'){
FB.api('/me/permissions', function(response) {
console.log(response);
if(response.data[1].status !== 'granted'){
retryToLogin();
}
});
}
}, {
scope: 'public_profile,email',
auth_type: 'rerequest'
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment