-
-
Notifications
You must be signed in to change notification settings - Fork 975
-
-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
request.env['omniauth.origin'] => nil in /auth/failure #569
Comments
I ran into the same issue. It turns out OmniAuth is behaving as expected. It's the default on_failure proc that's to blame. See line 25 in lib/omniauth.rb All you have to do is configure a new on_failure block. Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, 'consumer_key', 'consumer_secret'
on_failure do |env|
message_key = env['omniauth.error.type']
origin = env['omniauth.origin'].split('?').last
new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}&#{origin}"
[302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
end
end Now your failure method will have the origin URL params available to it. |
Awesome, thanks! I don't understand how this is omniauth behaving as expected though. The advertised behavior is that the origin should be available in the failure callback but it isn't. I'm glad there is a workaround however. Probably the default on_failure just needs to be updated to include the origin as you have done. |
Shouldn't omniauth also pass extra params defined by the user on failure? I encountered this problem and ended up on this page. I was able to solve it using the same method detailed here but it doesn't seem intuitive. This should at the very least be better documented in the wiki. There's even a 3 month old open issue about this. Now, since a pull request which added the provider to the redirect was accepted, it would make sense to add another pull request that adds user defined params to the redirect, don't you agree? |
Hi, I have checked out these issue but am having the same problem:
#227
#483
Versions I'm using:
Please let me know what other information you need.
The text was updated successfully, but these errors were encountered: