Omniauth Facebook not returning email and gender rails 4 -
i need fetch name, email, image , gender facebook. getting name , image, email , gender not fetched facebook. struggling past 2 days, can me out here.
user model:
def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_initialize.tap |user| user.provider = auth.provider user.uid = auth.uid user.name = auth.info.name user.email = auth.info.email user.gender = auth.extra.raw_info.gender #if user.gender.blank? user.image = auth.info.image user.save! end end
omniauth.rb
omniauth.config.logger = rails.logger rails.application.config.middleware.use omniauth::builder if rails.env.production? provider :facebook, 'app_id', 'app_sec' elsif rails.env.development? provider :facebook, 'app_id', 'app_sec', {:scope => 'publish_actions,email', :client_options => { :ssl => { :ca_file => "#{rails.root}/config/ca-bundle.crt" }}} else provider :facebook, 'app_id', 'app_sec' end end
if use user.gender = auth.extra.raw.gender if user.gender.blank?
returns null.
even have checked facebook privacy settings in public profiles only. can please me out here
add these changes data:
provider :facebook, 'app_id', 'app_sec_key', {:scope => 'email', :info_fields => 'email,name,first_name,last_name,gender', :client_options => { :ssl => { :ca_file => "#{rails.root}/config/ca-bundle.crt" }}}
Comments
Post a Comment