ruby on rails - Devise + Omniauth-Facebook get user's phone # -
i'm using devise authentication in rails 3.2 app , having trouble configuring omniauth-facebook
new user's phone number.
first of all: i'm not sure it's possible phone number, if that's case , knows sure, i'd happy confirmation.
it doesn't appear https://github.com/mkdynamic/omniauth-facebook "phone" part of fb auth hash default, though general omniauth schema have .info.phone (not required, of course). first idea it's fb permissions problem. i'm not sure permissions use, though, permissions facebook login page doesn't find phone value (maybe means it's not possible?).
i have phone
required attribute on user model, when try through fb new object never persists. works fine without looking phone number.
my config file:
# /config/initializers/devise.rb config.omniauth :facebook, 'facebook_app_id', 'facebook_app_secret', scope: 'email,public_profile', display: 'page'
in user model:
# user.rb def self.from_omniauth(auth) where(auth.slice(:provider, :uid)).first_or_create |user| user.email = auth.info.email user.password = devise.friendly_token[0,20] user.first_name = auth.info.first_name user.last_name = auth.info.last_name user.phone = auth.extra.raw_info.phone # have tried auth.info.phone end end
thanks in advance may able provide!
there's no way user's phone number facebook.
facebook's graph api reference lists user information can access via api. user's phone number not on list.
also, inspect contents of auth hash, add following line of code @ beginning of authentications/sessions/callbacks controller action:
render :text => "<pre>" + env["omniauth.auth"].to_yaml , return
you'll see there no phone
field @ auth.extra.raw_info
or auth.info
.
Comments
Post a Comment