Reputation: 1082
How to get user url from omniauth.hash? If user authorize with social(twitter, facebook, vk, etc.) I want to take link to their profile and put it on the page as link.
I use omniauth-facebook(and others) at rails 4. My config in initializers/devise.rb
is simple:
config.omniauth :vkontakte, 'APP_ID', 'APP_SECRET'
config.omniauth :facebook, 'APP_ID', 'APP_SECRET'
config.omniauth :twitter, 'APP_ID', 'APP_SECRET'
With this config I have very poor auth.hash on callback, in yml it looks so:
provider: facebook
uid: '***************'
info: !ruby/hash:OmniAuth::AuthHash::InfoHash
email: ****************
name: ****************
image: ************************
credentials: !ruby/hash:OmniAuth::AuthHash
token: ****************
expires_at: ******
expires: *****
extra: !ruby/hash:OmniAuth::AuthHash
raw_info: !ruby/hash:OmniAuth::AuthHash
name: ****************
email: ******************
id: '*******************'
I put *
instead real values, here no user url. According to https://github.com/mkdynamic/omniauth-facebook (scroll to the bottom) it should be: request.env['auth.hash'].extra.row_info.link or .info.urls.Facebook
How to get url?
Upvotes: 0
Views: 111
Reputation: 19193
Try this configuration:
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', info_fields: 'name,email,link'
Don't forget to restart the application.
Upvotes: 1