Cant get omniauth to work with refinery

183 views
Skip to first unread message

Federico Gonzalez

unread,
Mar 2, 2011, 7:03:28 PM3/2/11
to Refinery CMS
Hi, I have installed omniauth in a app using refinery.

But when i direct the user to the /auth/:provider route made available
by omniauth I get a page not found error. By looking at the parameters
I see that the :locale param is being passed.

Could these be the reason for not recognizing the omniauth route? If
so how can I stop refinery from passing it?

Thanks.

Philip Arndt

unread,
Mar 2, 2011, 7:07:15 PM3/2/11
to refine...@googlegroups.com
It's possible that the omniauth route does not have precedence over the pages route that catches all, but unlikely.

You could disable refinerycms-i18n in your Gemfile to test, however I *think* that the :locale parameter is handled by the routing and then deleted so other routes don't get touched by it.

Federico Gonzalez

unread,
Mar 3, 2011, 3:18:56 PM3/3/11
to Refinery CMS
I have run rake middleware:

use ActionDispatch::Static
use ActionDispatch::Static
use ActionDispatch::Static
use ActionDispatch::Static
use Rack::Lock
use Rack::Cache
use Dragonfly::Middleware
use Rack::Cache
use Dragonfly::Middleware
use Rack::Cache
use Dragonfly::Middleware
use Rack::Runtime
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::MethodOverride
use ActionDispatch::Head
use ActionDispatch::BestStandardsSupport
use Warden::Manager
use OmniAuth::Builder
run Researchers::Application.routes

So the omniauth does have precedence, also I tried removing the
refinerycms-i18n gem without luck. The only thing the worked was
removing refinery altogether.

Do you have any other ideas? Iam a bit lost, I don't know how to debug
it.

Thanks.
Federico

Federico Gonzalez

unread,
Mar 21, 2011, 8:34:14 PM3/21/11
to refine...@googlegroups.com, Federico Gonzalez
Anyone? Any ideas would be greatly appreciated.

Federico Gonzalez

unread,
Mar 21, 2011, 10:04:08 PM3/21/11
to refine...@googlegroups.com, Federico Gonzalez
I have figured it out myself. Posting the solution, in case anyone finds themselves in the same situation.

The way omniauth works is, by detecting a 404 error page, and if it matches the route /auth/:provider then it catches the request sends it to the provider. The reason it wasn't working with refinery is because refinery has a catch all route, which is why the request never returned a 404 error, which omniauth could detect.

What I did was create the following route:

match '/auth/:provider' => 'errors#error'

Then on the error action in the errors_controller I have:

render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false

Which is going to trigger a 404 error for omniauth to catch.

Hope it saves someone hours of hair pulling!

Joseph Ridgway

unread,
Apr 1, 2011, 3:16:35 PM4/1/11
to Refinery CMS
Won't this prevent Refinery from display legitimate 404s?

Joseph Ridgway

unread,
Apr 1, 2011, 3:19:49 PM4/1/11
to Refinery CMS
Nevermind. It works! Yay!
Reply all
Reply to author
Forward
0 new messages