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
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!
Any idea ? is it related to my app facebook settings ?
EDIT
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
Here is my gems used at Gemfile
gem ‘devise’
gem 'omniauth'
gem 'omniauth-facebook', '1.4.0'
gem 'oauth2'
Ok, I found it! Here is what facebook says here
So, I have to add ’email’ like this:
Thanks very much for all people who tried to help 🙂