简体   繁体   中英

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. i've setup authentication with 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). In my current setup everything is controlled by the gems, i've just configured all of them to work together.

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?

I tried few solutions from the community, but all of them suggested to have a sessions_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/

Here is their example from 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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