It was a routing problem.
Omniauth works by detecting a 404 error page:
if it matches the route /auth/:provider, then it catches the request sends it to the provider
... but comfortable-mexican-sofa cms (like refinery and others), has a catch all route, which is why the request never returned a 404 error, which omniauth could detect.
In comfortable-mexican-sofa case, it goes through "cms_path"=>"auth/github"
getting
NoMethodError in CmsContentController#render_html
undefined method `gsub!' for nil:NilClass
instead of the correct omniauth path which should go like following:
Started GET "/" for 127.0.0.1 at 2011-07-25 22:27:26 +0200
Processing by HomeController#index as HTML
Rendered home/index.html.haml within layouts/application (29.5ms)
Completed 200 OK in 44ms (Views: 42.8ms | ActiveRecord: 0.0ms)
Started GET "/auth/github" for 127.0.0.1 at 2011-07-25 22:27:35 +0200
MONGODB gitwatch_dev['users'].find({:provider=>"github", :uid=>1573})
Started GET "/auth/github/callback?code=4334bab983hd5fec19dd" for 127.0.0.1 at 2011-07-25 22:27:36 +0200
Processing by SessionsController#create as HTML
Parameters: {"code"=>"4334bab983hd5fec19dd", "provider"=>"github"}
Redirected to http://localhost:3001/
Completed 302 Found in 255ms
MONGODB gitwatch_dev['users'].find({:_id=>BSON::ObjectId('4e23114b1d41c80f180005b2')})
Started GET "/" for 127.0.0.1 at 2011-07-25 22:27:39 +0200
Processing by HomeController#index as HTML
Rendered home/index.html.haml within layouts/application (415.6ms)
Completed 200 OK in 890ms (Views: 428.6ms | ActiveRecord: 0.0ms)
The solution in my case is like the following :
in app/controllers/errors_controller.rb
class ErrorsController < ApplicationController
def error
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
end
end
in config/routes.rb add at the bottom
match '/auth/:provider' => 'errors#error'
... after Omniouth last route
`match "/auth/:provider/callback" => "sessions#create"`
thanks goes to Federico Gonzalez
and to Oleg Khabarov
I hope this will help someone else ;-)
bye Luca G. Soave