Open mhutter opened 10 years ago
I'm having the same exact problem with a Sinatra implementation of omniauth-twitter. If i set :callback_path, it returns to the correct place I specified in :callback_path, but request.env['omniauth.env'] is nil. And FYI, request.env['omniauth.origin'] is also nil, but you can access the value via rack session.
I'm also having the same problem. In my Rails 4.2 app, I've added following to my config/initializers/omniauth.rb
:
provider :foo, name: :bar, callback_path: "/sub/auth/bar/callback"
and in my callback controller, env['omniauth.auth']
is always nil
Any update im also having same problem?
I'm not sure if this is your issue, but I had an issue with the callback path not being recognised if it contained extraneous slashes (like //auth/ldap/callback
).
You may want to try removing the first slash and see if it works.
If you don't see the Callback Phase Initiated
message in your logs, then the callback_path was probably not recognised.
+1, have almost the same issue with rails 4.2.3 and omniauth 1.2.2. I see double slashes after callback (//auth/:provider/callback) and no Callback Phase Initiated
in logs. After removing one slash it works fine. But I don't customize callback_path
param
I'm having the same issue. Weirdly, it's not that request.env['omniauth.auth']
is nil, rather, it returns nil, which makes it even weirder. I inspected it in better_errors, and when I type just request.env
, it clearly shows the 'omniauth.auth' key and it's value, but for some reason, request.env['omniauth.auth']
returns nil nevertheless.
As soon as I remove the customized callback path, this behavior goes away, as OP suggested.
this happens in the following situation: (applies to 1.2.2 as well as the current master)
the following situation arises: -> "request.path_info" is set to "/internal/callback" by rack -> "on_callback_path" compares "my/custom/callback" with "/internal/callback" and returns false --> the method callback_call is never executed. --> env['omniauth'] is nil
I am facing this similar issue. Following are the gem versions used in my application.
ruby (2.3.0) rails (4.2.6) omniauth-facebook (3.0.0) omniauth-oauth2 (1.4.0) omniauth (1.3.1)
Did anyone found a solution or a work-around for this?
I have resolved my problem through a workaround. I have posted my solution in a gist. Hoping that it will be beneficial to people like me looking out for a solution to this problem.
External Links:
i was able to retrieve the necessary data by changing env["omniauth.auth"]
to request.env["omniauth.auth"]
Rails 5.1 Devise 4.3.0 omniauth (1.6.1) omniauth-facebook (4.0.0) omniauth-oauth2 (1.4.0)
Provider Gem: 'omniauth', '~> 1.2.1' Ruby Version: ruby 2.2.1p85 Platform: Ubuntu 14.04 LTS I want to create different login flow for admin, so I have create another sessions controller under admin. But when I try to access env["omniauth.auth"] from admin/sessions_controller.rb it shows error "NoMethodError at /admin/auth/identity/callback undefined method `[]' for nil:NilClass" I found env["omniauth.auth"] return nil Please help me
provider: identity
getting error
===============================================
undefined method `[]' for nil:NilClass
I want to call the post call api for sign in and sign up using omniauth identity
This issue has sprawled out to a bunch of different cases, but it does seem like the callback_path
option gets lost somehow.
For an alternative solution using querystring params, see https://github.com/omniauth/omniauth/issues/661#issuecomment-630300394
I had the same issue as outlined by tobias74 above - my app is behind a reverse proxy with a RAILS_RELATIVE_URL_ROOT
(also #903). My workaround is to add the relative URL component to full_host
and set the callback_path
to match the original (so "my/custom/callback" matches "/internal/callback" per tobias74) and use a querystring param (see above) if you then need to switch from the callback
OmniAuth.config.full_host = lambda do |_|
'https://www.example.com/my_relative_path'
end
config.omniauth :azure_oauth2,
client_id: ENV['AZURE_CLIENT_ID'],
client_secret: ENV['AZURE_CLIENT_SECRET'],
tenant_id: ENV['AZURE_TENANT_ID'],
callback_path: '/users/auth/azure_oauth2/callback'
rack 2.2.3 rails 5.2.0 omniauth 1.9.1
For me, simply setting both client_options.redirect_uri
and callback_path
did the trick. Note the former is relative, while the latter is a full URL (i.e. do not set to the same value). I guess client_options.redirect_uri
is to tell the provider, and callback_path
is where to expect the callback (from the standpoint of Omniauth).
Not sure you're affected by this issue? If you don't see Callback phase initiated
in your console after receiving the callback, Omniauth did not recognize the (customized) callback URL (i.e. it does not care that this particular request just came in).
I have a Rails app that "lives" in a subdirectory. To make sure the user gets to my app after authentication, I've added the following to my
config/initializers/omniauth.rb
:which works fine so far. However, now in my callback controller,
env['omniauth.auth']
is alwaysnil
Any Ideas to why this is happening?
I have an almost identical setup in another App (that's served from a Root directory) which works just fine.