在我的omniauth.rb
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email,public_profile', :display => 'popup', :info_fields => 'email,public_profile'
end
客户端,javascript:
return FB.login(function(response) {
if (response.authResponse) {
return window.location = '/auth/facebook/callback;
}
}, {scope: 'email,public_profile'});
根据 FB API 文档。
当 FB 弹出窗口打开请求权限时,它会正确请求电子邮件和 public_profile。我点击确定,这就是request.env['omniauth.auth]
我唯一提供的:
{"provider":"facebook","uid":"XXXXXXX","info":{"name":"XXXXXXX XXXXXXX","image":" http://graph.facebook.com/XXXXXXX/picture " },"credentials":{"token":"XXXXXXX","expires_at":1444467600,"expires":true},"extra":{"raw_info":{"name":"XXXXXXX XXXXXXX","id" :"XXXXXXX"}}}
除了全名和头像之外,我看不到电子邮件地址或任何公共信息。
我不知道我做错了什么,因为我完全遵循了omniauth-facebook gem 的指导方针:https ://github.com/mkdynamic/omniauth-facebook和 FB 开发者文档。
有什么提示吗?