get first_name and last_name fields from facebook omniauth

后端 未结 3 757
慢半拍i
慢半拍i 2021-02-15 15:58

I am now implementing omniauth feature into my app. Everything works fine except that i cant get the first and last name from the facebook. Here is my model code.



        
3条回答
  •  自闭症患者
    2021-02-15 16:14

    After some fiddling around i found the solution. Now i think we have to explicitly require the fields we require. For me the fix is just to add first_name and last_name to facebook.

    In my initializers i added first_name and last_name to info fields.

    info_fields: 'email, first_name, last_name'
    

    Update

    My full config file will look like this now

       config.omniauth :facebook, ENV["FACEBOOK_APP_ID"], ENV["FACEBOOK_SECRET"], scope: 'email', info_fields: 'email, first_name, last_name'
    

提交回复
热议问题