Facebook JavaScript SDK 通过 Omniauth-Facebook 获得额外权限
facebook javascript sdk get extra permissions with omniauth-facebook
我正在使用fb js sdk在omniauth-facebook上工作。它现在工作得很好,但是我不知道为什么它不能请求额外的权限。我已经在我的 omniauth.rb :scope 中为 omniauth-facebook 设置了,但是当我单击登录时,我没有得到任何我想从用户请求的额外权限。我通过互联网搜索,发现我必须这样做:
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
相关文章:
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 从选项页面更新chrome扩展清单权限
- 从应用程序脚本检查谷歌网站访问权限
- 在Nodejs中Express输入DEBUG=app时权限被拒绝/bin
- 如何使用Javascript客户端对象模型检索Sharepoint 2010列表项权限
- 如何将权限/授权数据传递到客户端Javascript
- 根据HTML文件名授予web服务器写入权限
- 如何在javascript清单中获取地理位置权限
- 如何在My chrome扩展中获取其他chrome扩展的DOM访问权限
- 如何在标志中检查权限
- 从另一个JSAppleScript运行另一个JS AppleScript时出现权限错误
- 为什么在中声明具有外部访问权限的变量
- webkitspeechrecognition不再提示获得权限
- AWS Lambda上的权限问题,可以't派生子进程
- 使用对数据库的写入权限保护文件
- 活动在magento中记录用户角色和权限
- 带有Cordova的iPhone上的位置权限警报
- 您没有权限调用msgbox
- 将字符串文件类型/权限转换为数字
- Facebook JavaScript SDK 通过 Omniauth-Facebook 获得额外权限