I am working on omniauth-facebook with fb js sdk. Now it works very well, but I do not know why it cannot request additional permissions. I already set in my omniauth.rb: scope for omniauth-facebook, but when I click login, I don’t have the extra permission that I want to request from the user. I search over the Internet and find out what I need to do:
FB.login(function(response) {
}, {scope: 'email,user_likes'});
But in my case, I follow on the client side and exit with this:
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
window.fbAsyncInit = function() {
FB.init({
appId : 'app_id',
channelUrl : '//'+window.location.hostname+'/channel',
status : true,
cookie : true,
oauth :true,
xfbml : true
});
FB.Event.subscribe('auth.login', function(response) {
if (response.authResponse) {
window.location = '/auth/facebook/callback';
}
}, {scope: 'email,user_likes'});
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
FB.api('/me', function(me){
if (me.name) {
document.getElementById('auth-displayname').innerHTML = me.name;
}
})
document.getElementById('auth-loggedout').style.display = 'none';
document.getElementById('auth-loggedin').style.display = 'block';
} else {
document.getElementById('auth-loggedout').style.display = 'block';
document.getElementById('auth-loggedin').style.display = 'none';
}
});
document.getElementById('auth-loginlink').addEventListener('click', function(){
FB.login();
});
document.getElementById('auth-logoutlink').addEventListener('click', function(){
FB.logout();
});
}
If I use the social facebook button and add an area to the html, it works, but that is not what I want. Has anyone here received a tutorial or tips to continue?
source
share