问题
I am trying to implement Facebook and Twitter authentication using Omniauth for an existing Rails 2.2 application. So far I have been unable to find any advise on how to do this in Rails 2.2 - hence this question. I have two questions to ask -
I understand Rack support for Rails was introduced from 2.3 and I believe Rack is needed for OmniAuth. So is it even possible to use OmniAuth on a Rails 2.2 website and why ?
If it is possible to implement OmniAuth - how would you do it ?
回答1:
You can't use the default config.gem "omniauth" ... to get it working i did the following:
1.Install omniauth manually
sudo gem install omniauth
2.Require it before the Rails Initializer in the config/environment.rb file.
require 'omniauth'
Rails::Initializer.run do |config| ....
3.In development.rb file i've added the following configuration
config.middleware.use OmniAuth::Builder do
provider :facebook, "XXx", "YYYY", :scope => % (email user_birthday publish_stream offline_access)
end
Add as many providers as you want here .... everything else should work as expected.
来源:https://stackoverflow.com/questions/5165544/how-do-you-implement-omniauth-on-rails-2-2