Cant get omniauth to work with refinery

Showing 1-7 of 7 messages
Cant get omniauth to work with refinery Federico Gonzalez 3/2/11 4:03 PM
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.
Re: [Refinery CMS:2803] Cant get omniauth to work with refinery Philip Arndt 3/2/11 4:07 PM
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.

Re: Cant get omniauth to work with refinery Federico Gonzalez 3/3/11 12:18 PM
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
Re: Cant get omniauth to work with refinery Federico Gonzalez 3/21/11 5:34 PM
Anyone? Any ideas would be greatly appreciated.
Re: Cant get omniauth to work with refinery Federico Gonzalez 3/21/11 7:04 PM
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!

Re: Cant get omniauth to work with refinery Joseph Ridgway 4/1/11 12:16 PM
Won't this prevent Refinery from display legitimate 404s?
Re: Cant get omniauth to work with refinery Joseph Ridgway 4/1/11 12:19 PM
Nevermind. It works! Yay!