After trying to "log in with Google", I'm seeing this error in the logs:
Processing by Users::OmniauthCallbacksController#failure as HTML
I can see all the data from google being sent through the URL (in the logs), including user email and name. So what could go wrong? My callbacks aren't even being executed. I only get redirected to the sign_in page of my site.
And I'm pretty sure everything is configured correctly, because this was working fine some weeks ago. I don't think I changed anything. Facebook login still works fine.
Any ideas on how to debug this failure? There is nothing else in the logs, other than those long URLs full of parameters and values. Only INFO messages. The one posted above is the only one that said something about a failure.
UPDATE
I added a 'failure' method to the controller
def failure
render :text => params.inspect
end
Which stopped the redirects, and printed this:
{}
The url was this:
/users/auth/google/callback?_method=post&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2012-04-16T12%3A25%3A49Z_v1fNngSQJaHBQ&openid.return_to=http%3A%2F%2Fdev.myapp.me%3A3000%2Fusers%2Fauth%2Fgoogle%2Fcallback%3F_method%3Dpost&openid.assoc_handle=AMlYA9Urw_lYamPphTSdQ9a6DU0Ez0y5RaDDM78qPL7Xgm77nMpJiB85&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.ext5%2Cext1.value.ext5%2Cext1.type.ext8%2Cext1.value.ext8%2Cext1.type.ext2%2Cext1.value.ext2&openid.sig=2FPjo7U1e%2Fde248XpUgjQLduNAM%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk1F5U6x_-kJnydjoww5haU41tquh1Zl2c&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk1F5U6x_-kJnydjoww5haU41tquh1Zl2c&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.ext5=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffirst&openid.ext1.value.ext5=Some_User&openid.ext1.type.ext8=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.ext8=some_email%40gmail.com&openid.ext1.type.ext2=http%3A%2F%2Faxschema.org%2FnamePerson%2Flast&openid.ext1.value.ext2=Some_User
So the thing is that all the data I need is in the URL, but devise/omniauth is not grabbing it (and apparently that's why it's calling the 'failure' method instead of my callbacks). I don't know if it should be accessible through the 'params' array, or what.
I'm also intrigued about the ?_method=post
part, because all the requests to my site are GET requests. Maybe it just means that the request done by omniauth to google was POST.
Any thoughts?
To answer the original question about how you debug Omniauth, here's how to enable logging for Omniauth. Add this line to config/initializers/devise.rb
just after you define your Omniauth strategies:
OmniAuth.config.logger = Rails.logger if Rails.env.development?
(If you're not using Devise, just Omniauth, then add the code instead to config/initializers/omniauth.rb
)
You'll get loads more information from Omniauth in your log file - including the full response from the callback phase.