How can I specifiy what access I need from my user's Facebook accounts when using OmniAuth?

只愿长相守 提交于 2019-12-03 08:49:35
shingara

You can check on option using the :scope attribute:

use OmniAuth::Strategies::Facebook, 'app_id', 'app_secret', {:scope => 'email,offline_access, your,scope,you,want'}

Check the Facebook permissions documentation what scope you really want and define it separate by a commant on :scope option.

If you use an initializer to define your OamniOauth, it's like that:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, 'APP_ID', 'APP_SECRET', {:scope => 'email,offline_access, your,scope,you,want'}
end

If you are using devise (like me) the easiest solution is to have both 'devise' and 'omniauth-facebook' in your Gemfile. Then in your devise initializer you can just add:

config.omniauth :facebook, "app", "secret", :scope => "user_photos"

This does the trick pretty well. Adding the omniauth initializer with devise set-up

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