Search code examples
ruby-on-railsomniauth

request.env['omniauth.auth']["info"]["email "] returns nil


I have a rails application and I am using omniAuth to authorise Facebook login and my problem is that Facebook did not return emails.

Here is the data:

 ruby '2.1.7'
 Graph API V2.5

I have both gems'omniauth'and'omniauth-facebook'installed. is there a specific gem version for 'omniauth' and 'omniauth-facebook' that I should install ?

In my config.omniauth I added

info_fields: 'email

but unfortunately I am still facing the same issue.

I tried these below solutions but none of them worked for me

why facebook email is not retrieved?

I added as well the email as well when calling this function

 FB.api('/me?fields=name, email', function(response) {
      console.log(response);
        'Thanks for logging in, ' + response.email + '!';
    });

FYI: I am testing the application with real users whom address emails were verified and when connecting to Facebook I am entering the address email not the phone number.

Any help would be appreciated. Thanks!


Solution

  • Try to check koala gem you can specify the version and fields you want to return.