Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OmniAuth invalid_response with Twitter

Using OmniAuth, Rails 3.1.0.rc2, mysql2, ruby 1.9.2.p0.

I still get this when redirecting back to my site.

/auth/failure?message=invalid_response

Omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, 'XXXXX', 'XXXXXXXXXXXXX'

I've checked the keys 100x and they are correct. Still getting the invalid response. Any of the questions I see don't seem to work.

Any help would be greatly appreciated!

Thanks. [:

If any new information is needed, just ask.

like image 541
nbucciarelli Avatar asked Dec 22 '22 13:12

nbucciarelli


2 Answers

If you use this request.env['rack.auth'] in your controller, change this to request.env['omniauth.auth'] - this were explained here OmniAuth

this solution works for me.

like image 194
bor1s Avatar answered Dec 24 '22 01:12

bor1s


I had a similar problem. It turns out that I actually had some runtime errors in my Users::OmniauthCallbacksController#twitter method:

I was calling a method on a non-existent method on a nil object and this was raising an exception, but either devise or omniauth were swallowing the exception.

I ended up wrapping my entire method body in a begin/rescue clause and printing out the exception.

However, if you are getting Invalid Credentials then it's likely that the twitter-issued oauth key has expired and so your user should really be calling /users/auth/twitter again.

like image 34
bobc Avatar answered Dec 24 '22 03:12

bobc