spree_social
spree_social copied to clipboard
OmniAuth hardcoded info_fields
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?
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
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.