Has anyone used omniauth with rails 2.3.8?

六月ゝ 毕业季﹏ 提交于 2019-12-04 12:15:49

问题


I am new to Rails and I am trying to use omniauth with rails 2.3.8. I couldn't find any tutorial for this version of rails so I referred to http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth.

I added the initializer as follows:

omniauth.rb

OmniAuth::Strategies::Twitter = { 
    :consumer_key => 'xxxxxx', 
    :consumer_secret => 'xxxxxx' 
} 

After this step if I try to hit the URL '/auth/twitter' then I get "No route matches "/auth/twitter" with {:method=>:get}".

Has anyone used omniauth with rails 2.3.8?


回答1:


OmniOauth is a Rack::Middleware. So you need use it like that.

So you need add like that :

ActionController::Dispatcher.middleware.use OmniAuth::Strategies::Twitter = { 
    :consumer_key => 'xxxxxx', 
    :consumer_secret => 'xxxxxx' 
} 



回答2:


This is how it works for me in rails 2.3.8

omniauth.rb:

ActionController::Dispatcher.middleware.use OmniAuth::Builder do
  provider :facebook,
    "key", "secret", 
    :scope => %(email user_birthday publish_stream offline_access),
    :client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
end


来源:https://stackoverflow.com/questions/4062674/has-anyone-used-omniauth-with-rails-2-3-8

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