omniauth with rails: get facebook user's information

泪湿孤枕 提交于 2019-12-24 09:16:22

问题


in the callback of the authentication process I do:
auth_hash = request.env['omniauth.auth']

and then, I'm extracting the user id, but is it possible in the same time getting the user's name and email address?


回答1:


You need to first get the raw data from request.env["omniauth.auth"]

  data = request.env["omniauth.auth"].extra.raw_info 
  username = data.first_name 
  email  = data.email 



回答2:


yesss

u can get it by doing

     auth_hash[:info][:name] for name and auth_hash[:info][:email] for email


来源:https://stackoverflow.com/questions/13207211/omniauth-with-rails-get-facebook-users-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!