如何使用 omniauth-facebook gem 获取 facebook 个人资料数据?

How to fetch facebook profile data using omniauth-facebook gem?

我也是 ruby 和 rails 的初学者,我正在 rails-angular stack.The rails 应用是 JSON API。我已经使用 device_token_auth、omniauth_facebook、omniauth_google_outh2 设置身份验证。到目前为止,身份验证部分工作正常。现在的问题是,我需要从 facebook 和 google(照片、关于我、位置等)获取一些额外的数据。在我当前的设置中,一切都由 gem 控制,我刚刚将它们全部配置为协同工作。

谁能帮我解决这个问题

为了能够获取我需要的信息,我是否必须编写自定义控制器和模型?

如果我必须修改 gem 方法、模型和控制器,我该怎么做?

我尝试了社区中的一些解决方案,但他们都建议使用 sessions_controller。但我不能在这里这样做,因为我使用的是基于令牌的身份验证。谢谢

根据 omniauth-facebook readme: scope is "A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: https://developers.facebook.com/docs/reference/login/

这是来自 Github 的示例:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'],
  scope: 'email,user_birthday,read_stream', display: 'popup'
end