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!
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.