带Rails的omniauth:获取Facebook用户信息 [英] omniauth with rails: get facebook user's information

查看:94
本文介绍了带Rails的omniauth:获取Facebook用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在身份验证过程的回调中,我要做:
auth_hash = request.env['omniauth.auth']

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

然后,我要提取用户ID,但是是否可以同时获取用户名和电子邮件地址?

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

推荐答案

您需要首先从request.env ["omniauth.auth"]

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 

这篇关于带Rails的omniauth:获取Facebook用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆