2
votes

In my 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

Client side, javascript:

return FB.login(function(response) {
  if (response.authResponse) {
    return window.location = '/auth/facebook/callback;
   }
}, {scope: 'email,public_profile'});

as per the FB API docs.

When the FB popup opens to ask for permissions, it correctly asks for email and public_profile. I hit OK and this is what request.env['omniauth.auth] provides me with only:

{"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"}}}

I see neither the email address nor any public info except the full name and the profile picture.

I have no clue what I'm doing wrong as I follow exactly the guidelines of the omniauth-facebook gem here: https://github.com/mkdynamic/omniauth-facebook and also the FB developer docs.

Any hints?

1

1 Answers

1
votes

You are on the right path just need to update the info fields with the fields you want to pull from facebook, public_profile won't work

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, Rails.application.secrets[:facebook_app_id], Rails.application.secrets[:facebook_secret], :scope => 'email', :display => 'popup', :info_fields => 'email,first_name,last_name'
end