Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Omniauth facebook - Auth info fields

I am trying to setup omniauth for a website for login through facebook. The issue is facebook is not sending the 'info' field.

I have setup 2 facebook apps for different environment.

For one app the response has the fields

#<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=14
42913734 token="CAAU6NSaozowBANJoDeZCakDuUZAiIZBGQ5cmFYRTwQwo7SK2JK7uhcRK7WIadpp
zjKfict9pMASS2k9XJZBTgnI8WJvJA42er9Xj8nuoeLjbEQo8TKB7b5hVlsOwRs5kcPpOPwyUTUc0ekF
uu2w4ubNZBMXZBw5xjGkQwZBZA46fATGOvDXJSrWOOAiQteWnkSO9JkeZC2SfmZCQqcSR0zdV52"> ex
tra=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash id="xxxxxxxxxx" na
me="xxxxxxx">> info=#<OmniAuth::AuthHash::InfoHash image="http://graph.facebo
ok.com/xxxxxxxxxxx/picture" name="xxxx"> provider="facebook" uid="xxxxxxxx">

In the development env I get the response

#<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=14
42912896 token="CAAPK1ZAgrDtEBAKKvcj4jGu6iaIxYYJV7LZCJ6MZCELZCgNyowkqPeB5kHBsVw4
ZBKoZCv4DD6my4s8qhO1hJyEFzcb1IpKt03ydzWORZCR3PCf1bw6A9jRudmcJn1N37WgqckmuKUj4k1y
qb3fcRpNPxAxx0asXJlaUJTcVR5wi0sRIOc9l3yFm6XyuMA464MBz5vt9AvNcVB9DAGm5kHr"> extra
=#<OmniAuth::AuthHash raw_info=#<OmniAuth::AuthHash email="[email protected]"
first_name="xxxx" gender="male" id="xxxxx" last_name="xxxx" link="h
ttps://www.facebook.com/app_scoped_user_id/xxxx/" locale="en_US" na
me="xxxx" timezone=10 updated_time="2015-06-06T03:35:33+0000" verified=tru
e>> info=#<OmniAuth::AuthHash::InfoHash email="xxxxxxx" first_name="
xx" image="http://graph.facebook.com/xxx/picture" last_name="xxxxx" name="xxxxx" urls=#<OmniAuth::AuthHash Facebook="https://www.facebook.c
om/app_scoped_user_id/xxxxx/"> verified=true> provider="facebook" ui
d="xxxxxxxxxxxxxxxx">

I wonder if it is a app level setting because the code is same for both. Only difference on the app side is one is API v2.3 and other is 2.4

like image 960
sethi Avatar asked Jul 24 '15 10:07

sethi


1 Answers

There is difference when you use v2.3 and v2.4.

In your config/initializers/devise.rb file or wherever you have put your API key, you have to add info_fields, besides scope,

example

config.omniauth :facebook, APP["facebook_id"], APP["facebook_secret"],
    :scope => 'email,public_profile', info_fields: 'email,name'
like image 102
Nermin Avatar answered Nov 15 '22 03:11

Nermin