0

Within my rails app, when someone signs up with Facebook, I'm trying to grab their email, name, image, location, bio, website.

I'm using Omniauth Facebook Here is the guide I followed.

The signup works smoothly, I get no errors in the browser or in my logs, but the location, bio, and website all come back as nill. What could be causing this? How can I fix this?

Am I allowed to call on user_location, user_about_me, user_website?

https://developers.facebook.com/docs/facebook-login/permissions/v2.2?locale=en_GB#reference

Gem file:

gem 'devise'
gem 'omniauth-facebook'

User.rb

  def self.from_omniauth(auth)
  where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
    user.email = auth.info.email
    user.password = Devise.friendly_token[0,20]
    user.name = auth.info.name  
    user.image = auth.info.image 
    user.location = auth.info.user_location 
    user.about = auth.info.user_about_me 
    user.website = auth.info.user_website 
  end
end

Devise.rb initializer

  config.omniauth :facebook, "APP_ID", "APP_SECRET",
          scope: 'email, user_location, user_about_me, user_website',
                  strategy_class: OmniAuth::Strategies::Facebook

Any help would be much appreciated!

Katie H
  • 2,283
  • 5
  • 30
  • 51
  • 1
    It looks like the "about me" and "website" isn't included in public profile and the locale has additional requirements, are you satisfying those? - https://developers.facebook.com/docs/facebook-login/permissions/v2.2?locale=en_GB#reference – Ken Stipek Dec 10 '14 at 01:13
  • Hey Ken! You're right, I have no clue how to satisfy the additional requirements. Is there some token or variable I have to store? Do I need to call on something like .extra.raw_info ? http://stackoverflow.com/questions/13207211/omniauth-with-rails-get-facebook-users-information – Katie H Dec 10 '14 at 01:28
  • I'm afraid not, sorry :( – Ken Stipek Dec 10 '14 at 02:43

1 Answers1

1

The Facebook API documentation is rather confusing.

The problem is not with the rails code or the omniauth gem.

By default, Facebook only approves your application for grabbing a user's name, email, image, and a few other attributes.

To be able to grab any user's location, bio, or website, you need to individually apply for permission for each of these.

Katie H
  • 2,283
  • 5
  • 30
  • 51