Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OmniAuth hardcoded info_fields #223

Open
mightymatth opened this issue Sep 18, 2018 · 2 comments
Open

OmniAuth hardcoded info_fields #223

mightymatth opened this issue Sep 18, 2018 · 2 comments

Comments

@mightymatth
Copy link

mightymatth commented Sep 18, 2018

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?

@storhet
Copy link

storhet commented Dec 5, 2018

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

@andretf
Copy link

andretf commented Apr 21, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants