简体   繁体   English

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

[英]How to fetch facebook profile data using omniauth-facebook gem?

I'm a beginner to ruby and rails too, i'm developing a web app on rails-angular stack.The rails app is a JSON API. 我也是ruby和rails的初学者,我正在Rails-Angular Stack上开发Web应用程序。rails应用程序是JSON API。 i've setup authentication with device_token_auth,omniauth_facebook, omniauth_google_outh2. 我已经使用device_token_auth,omniauth_facebook,omniauth_google_outh2设置了身份验证。 Authentication is part is working fine so far. 到目前为止,身份验证工作还不错。 The problem now is, i need fetch some additional data from facebook and google (photo,about me,location etc). 现在的问题是,我需要从facebook和google获取一些其他数据(照片,关于我,位置等)。 In my current setup everything is controlled by the gems, i've just configured all of them to work together. 在我当前的设置中,一切都由gems控制,我刚刚将它们配置为可以一起工作。

Can someone please help me with the approach 有人可以帮我解决这个问题吗

To be able to fetch the info i need, do i have to write custom controllers and models ? 为了获取我需要的信息,我是否必须编写自定义控制器和模型?

If i have to modify gem methods,models and controllers, how can i do that? 如果我必须修改gem方法,模型和控制器,该怎么办?

I tried few solutions from the community, but all of them suggested to have a sessions_controller. 我尝试了来自社区的一些解决方案,但所有这些建议都建议使用session_controller。 but i can't do that here because i'm using token based authentication. 但是我不能在这里这样做,因为我使用的是基于令牌的身份验证。 Thanks 谢谢

As per the 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/ 按照omniauth-facebook 自述文件scope是“您要向用户请求的权限的逗号分隔列表。有关可用权限的完整列表,请参阅Facebook文档: https : //developers.facebook.com/docs/参考/登录/

Here is their example from Github: 这是来自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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM