You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Facebook authentication not working with custom callback path #661
I'm not sure if this is related to issue #630 or not. I posted this as a question on Stack Overflow, but I'll post it again here as I feel like it may be a bug:
I'm using devise / omniauth to authenticate my Rails app against Facebook. I'm trying to change the callback_path to be something custom, but no matter what I set it to, the omniauth.auth request variable comes back as nil. For example, here I'm setting the callback_path to the exact value that it is if I don't set it:
If I don't set the :callback_path, then authentication works and I get data back in the omniauth.auth request variable. But, I have to override it because I need to support passing an attribute back on the callback.
I've looked through the Omniauth::Strategy code to see what might be going wrong, but I can't quite figure out what's going wrong.
My questions:
Is this a bug?
Why is this not working?
Is there a better way to solve the problem?
Definitely seems like a bug. The callback_path that is set by setup proc gets lost somehow. I tried tracking it down, but ran out of time. It's in the Omniauth::Strategy::Options during the request phase, but doesn't appear in the callback request.
In any case, a workaround is to use a querystring param on your provider URL, e.g. /auth/<provider>?my_auth_type=some_value'. The param will get passed back to you with the callback request. In your controller's callback action, you can then examine the value of params[:my_auth_type]` and write your logic based on that.
I've verified that this works for Auth0 but haven't tried it on others.
OmniAuth decides whether a request is the callback before the setup phase runs, so a callback_path set in setup affects the URL sent to the provider, but the callback request then never matches it. (The example's path is also missing its leading slash.) Pass callback_path as a provider option instead, as a string or as a lambda that returns true for the callback request. Closing since this is how it's designed.
Activity
brauliobo commentedon Dec 19, 2013
had to force this too with persona and twitter. The use callback_path in the provider method call with setup doesn't seems to work
delacruzjames commentedon Feb 11, 2015
any work around for this?
wangthony commentedon May 18, 2020
Definitely seems like a bug. The
callback_paththat is set by setup proc gets lost somehow. I tried tracking it down, but ran out of time. It's in theOmniauth::Strategy::Optionsduring the request phase, but doesn't appear in the callback request.In any case, a workaround is to use a querystring param on your provider URL, e.g.
/auth/<provider>?my_auth_type=some_value'. The param will get passed back to you with the callback request. In your controller's callback action, you can then examine the value ofparams[:my_auth_type]` and write your logic based on that.I've verified that this works for Auth0 but haven't tried it on others.
Ignore query params when we check current_path
Ignore query params when we check current_path
Add proxy_to param to callback_path
Add proxy_to param to callback_path
Add proxy_to param to callback_path
Add proxy_to param to callback_path
sferik commentedon Oct 20, 2026
OmniAuth decides whether a request is the callback before the setup phase runs, so a
callback_pathset insetupaffects the URL sent to the provider, but the callback request then never matches it. (The example's path is also missing its leading slash.) Passcallback_pathas a provider option instead, as a string or as a lambda that returns true for the callback request. Closing since this is how it's designed.