simi / omniauth-facebook

Facebook OAuth2 Strategy for OmniAuth
https://simi.github.io/omniauth-facebook/
1.26k stars 403 forks source link

first_name blank #384

Closed dcalixto closed 1 year ago

dcalixto commented 1 year ago

Hello i'm trying to get the facebook first name to put on username on omniauth-facebook gem

but just get the name, looking at facebook docs indeed has first_name but how to get it?

here is the code

  def self.from_omniauth(access_token)
    data = access_token.info
    user = User.where(email: data['email']).first
    user ||= User.create(name: data['name'],
                         email: data['email'],
                         username: data['first_name'],
                         avatar_url: data['image'],
                         provider: access_token['provider'],
                         uid: access_token['uid'],
                         password: Devise.friendly_token[0, 20])

    user
  end

i tried the info_fields but did not worked

  config.omniauth :facebook, '', '', scope: 'email', info_fields: 'first_name'

so someone can help?

dcalixto commented 1 year ago

ok, fixed, just forget to restart the server!

u296539883 commented 1 year ago

2D884847-98F8-476F-BDCA-9E2309CDA566