spree_social icon indicating copy to clipboard operation
spree_social copied to clipboard

OmniAuth hardcoded info_fields

Open mightymatth opened this issue 6 years ago • 2 comments

When using Facebook as OmniAuth provider, I want to retrieve first_name and last_name instead of name. The problem is located here where info_fields value is hardcoded to 'email, name' instead of being extendable (in my case to 'email, first_name, last_name'). Is there any reason why you hardcoded this? Also, is there any way to properly override this module method?

mightymatth avatar Sep 18 '18 09:09 mightymatth

I'm having similar problem. I have custom omniauth gem which requires additional params to be passed (scope, base_uri) when we setup config.omniauth. And it will be great if there was a possibility to make setup_key_for method a bit more flexible

storhet avatar Dec 05 '18 14:12 storhet

you can override by creating a decorator as defined here: https://github.com/spree-contrib/spree_social/blob/7963d4246b56e297e4ea7461e22bbe2a66ad20b7/lib/spree_social/engine.rb#L29:L33

ie: app/<some_path>/engine_decorator.rb:

OmniAuth::Strategies::Facebook.class_eval do
  def request_phase
    options[:scope] ||= 'email'
    options[:info_fields] = 'first_name,last_name,email'
    options[:display] = mobile_request? ? 'touch' : 'page'
    super
  end
end

I know it's not a definitive solution, I agree it should be dynamic, but it should work for now.

andretf avatar Apr 21 '19 19:04 andretf