js-api首次登录后没有扩展权限
js api no extended permissions after initial login
我正在尝试在我的应用程序中设置请求用户电子邮件的权限。
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function(response) {
//window.location.reload();
window.location = "/welcome.html";
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div id="fb-root"></div>
<div class="fb-login-button" data-scope="email" >
Login with Facebook
</div>
当用户当前登录到facebook时,他们会看到一个对话框,要求他们允许我的应用程序。它还要求获得使用他们电子邮件的许可。这是预期的行为,并且有效。
当用户当前没有登录到facebook时,他们会看到一个登录对话框(这也是意料之中的事,而且有效),下一个出现的对话框是允许我的应用程序的对话框,但它没有访问他们电子邮件的权限,这就是我遇到麻烦的地方。
我已经阅读并尝试了其他问题中描述的各种方法。就像用onclick调用FB.login方法并以这种方式设置权限范围,但仍然没有成功。
FB.login(function(response) {
if (response.authResponse) {
window.location = "/welcome.html";
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
}, {scope: 'email'});
我知道这是可能的,因为我已经看到其他几个应用程序正确地做到了这一点,我只是看不出我缺少了什么。我也尝试过xfbml方法,但遇到了与div相同的问题。
订阅该auth.login
事件时要小心。当SDK在FB.init()
中看到status : true
时,它甚至在执行登录检查时被调用。
请注意我在这里使用它的操作:http://jsfiddle.net/dmcs/R4g47/(它被注释掉了,但你取消注释并运行脚本。你可以看到你想注意发送到它的状态。
FB.Event.subscribe('auth.login', function(response) {
// {
// status: "", /* Current status of the session */
// authResponse: { /* Information about the current session */
// userID: "" /* String representing the current user's ID */
// signedRequest: "", /* String with the current signedRequest */
// expiresIn: "", /* UNIX time when the session expires */
// accessToken: "", /* Access token of the user */
// }
// }
alert('event status: ' + response.status);
});
相关文章:
- 从选项页面更新chrome扩展清单权限
- 如何在My chrome扩展中获取其他chrome扩展的DOM访问权限
- Chrome 扩展程序权限不起作用
- Chrome 扩展程序 - Notification.requestPermission() 不请求权限
- Facebook扩展权限由用户授予
- 添加 file://.对 Chrome 扩展程序的权限
- Chrome 扩展程序权限
- 授予 Chrome 扩展程序对 iframe 内容的访问权限
- Chrome 扩展程序内容安全政策和权限
- Chrome 扩展程序 - 请求当前标签页的可选权限
- Chrome 扩展程序清单权限
- Chrome扩展声明权限混淆
- Chrome扩展权限XMLHttpRequest
- 在JS扩展中使用chrome.bluetooth.AddProfile的权限被拒绝
- js-api首次登录后没有扩展权限
- Chrome-查找哪些其他扩展正在使用特定权限
- Chrome扩展-请求新的权限
- 在Facebook上用Javascript请求扩展权限的正确方法是什么?
- Chrome扩展权限"about:blank"页面
- Chrome扩展权限(读取网站中的数据)