facebook javascript sdk通过omniauth facebook获得额外权限
我正在使用fb js sdk开发omniauth facebook。它现在运行得很好,但是我不知道为什么它不能请求额外的权限。我已经在omniauth.rb:scope中设置了omniauth facebook,但当我单击“登录”时,我并没有从用户那个里获得任何额外的权限。我在互联网上寻找,发现我必须这样做:facebook javascript sdk通过omniauth facebook获得额外权限,javascript,facebook,permissions,facebook-javascript-sdk,omniauth,Javascript,Facebook,Permissions,Facebook Javascript Sdk,Omniauth,我正在使用fb js sdk开发omniauth facebook。它现在运行得很好,但是我不知道为什么它不能请求额外的权限。我已经在omniauth.rb:scope中设置了omniauth facebook,但当我单击“登录”时,我并没有从用户那个里获得任何额外的权限。我在互联网上寻找,发现我必须这样做: FB.login(function(response) { // handle the response }, {scope: 'email,user_likes'}); 但在我的案例中
FB.login(function(response) {
// handle the response
}, {scope: 'email,user_likes'});
但在我的案例中,我遵循客户方的观点,并得出以下结论:
(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));
// Init the SDK upon load
window.fbAsyncInit = function() {
FB.init({
appId : 'app_id', // App ID
channelUrl : '//'+window.location.hostname+'/channel', // Path to your Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth :true, //enable Oauth 2.0
xfbml : true // parse XFBML
});
// listen for and handle auth.statusChange events
//
FB.Event.subscribe('auth.login', function(response) {
if (response.authResponse) {
window.location = '/auth/facebook/callback';
}
}, {scope: 'email,user_likes'}); //i tried but its not working
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
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 {
// user has not auth'd your app, or is not logged into Facebook
document.getElementById('auth-loggedout').style.display = 'block';
document.getElementById('auth-loggedin').style.display = 'none';
}
});
// respond to clicks on the login and logout links
document.getElementById('auth-loginlink').addEventListener('click', function(){
FB.login();
});
document.getElementById('auth-logoutlink').addEventListener('click', function(){
FB.logout();
});
}
如果我使用facebook社交按钮并在那里添加html的作用域,它可以工作,但这不是我想要的。这里有人给了我继续学习的教程或提示吗?这个怎么样:
jQuery ->
$('body').prepend('<div id="fb-root"></div>')
$.ajax
url: "#{window.location.protocol}//connect.facebook.net/en_US/all.js"
dataType: 'script'
cache: true
window.fbAsyncInit = ->
FB.init(appId: '<%= ENV["FACEBOOK_KEY"] %>', cookie: true)
$('#sign_in').click (e) ->
e.preventDefault()
FB.login (response) ->
window.location = '/auth/facebook/callback' if response.authResponse
, scope: "email, publish_stream"
$('#sign_out').click (e) ->
FB.getLoginStatus (response) ->
FB.logout() if response.authResponse
true
jQuery->
$('body')。前缀(“”)
$.ajax
url:“#{window.location.protocol}//connect.facebook.net/en#u US/all.js”
数据类型:“脚本”
缓存:真
window.fbAsyninit=->
FB.init(appId:“”,cookie:true)
$(“#登录”)。单击(e)->
e、 预防默认值()
FB.login(响应)->
window.location='/auth/facebook/callback'if response.authResponse
,范围:“电子邮件,发布流”
$(“#注销”)。单击(e)->
FB.getLoginStatus(响应)->
FB.logout()如果response.authResponse
真的