为什么没有检索到Facebook电子邮件? [英] why facebook email is not retrieved?

查看:286
本文介绍了为什么没有检索到Facebook电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户接受使用他的facebook帐户登录后,我的应用程序回调将由facebook调用,我注意到facebook没有检索用户电子邮件,尽管在omniauth的配置中,我已在这样的权限列表:

After user accept to sign in with his facebook account, my app callback will be called by facebook, I've noticed that facebook didn't retrieved user email, although in the configuration of omniauth, I've listed email in the permission list like this:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, omniauth_app_id, omniauth_app_secret_id,
           :scope => 'email,user_birthday,read_stream', :display => 'popup'
end

我希望在request.env['omniauth.auth']['extra']['raw_info']['email']request.env['omniauth.auth']['info']['raw_info']['email']中找到电子邮件 但是,它实际上不存在..实际上,它不在request对象内的任何属性中!

I am expecting to find email in request.env['omniauth.auth']['extra']['raw_info']['email'] or request.env['omniauth.auth']['info']['raw_info']['email'] But, its not there .. in fact, its not in any attribute within the request object!

有什么主意吗?它与我的应用程序Facebook设置有关吗?

Any idea ? is it related to my app facebook settings ?

编辑

这是Facebook的回叫结果:

Here is the call back result from Facebook:

puts auth.inspect

#<OmniAuth::AuthHash credentials=#<Hashie::Mash expires=true expires_at=1353164400 token="***"> extra=#<Hashie::Mash raw_info=#<Hashie::Mash first_name="***" id="***" last_name="***" link="***" locale="ar_AR" name="***" timezone=2 updated_time="2012-11-17T13:01:59+0000" username="***" verified=true>> info=#<OmniAuth::AuthHash::InfoHash first_name="***" image="***" last_name="***" name="***" nickname="***" urls=#<Hashie::Mash Facebook="***"> verified=true> provider="facebook" uid="***">

我已经用 * 替换了真实数据,但是,您可以看到电子邮件数据丢失了..

I have replaced reall data with *, but, you can see that the email data is missing ..

EDIT2

这是我在Gemfile中使用的宝石 宝石设计"

Here is my gems used at Gemfile gem 'devise'

gem 'omniauth'
gem 'omniauth-facebook', '1.4.0'

gem 'oauth2'

推荐答案

好,我找到了!这是Facebook在此处

Ok, I found it! Here is what facebook says here

默认情况下,调用FB.login将尝试对用户进行身份验证 仅具有基本权限.如果您想要一个或多个其他 权限,使用选项对象调用FB.login并设置范围 参数,以逗号分隔的您希望的权限列表 来自用户的请求.

By default, calling FB.login will attempt to authenticate the user with only the basic permissions. If you want one or more additional permissions, call FB.login with an option object, and set the scope parameter with a comma-separated list of the permissions you wish to request from the user.

因此,我必须像这样添加电子邮件":

So, I have to add 'email' like this:

 FB.login(function(response) {
   // handle the response
 }, {scope: 'email,user_likes'});

非常感谢所有尝试提供帮助的人:-)

Thanks very much for all people who tried to help :-)

这篇关于为什么没有检索到Facebook电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆