I have a Rails 3.1 application with devise 1.5.3 , omniauth 1.0.1 and omniauth-github 1.0.1 .
configurations / initializers / devise.rb
config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
configurations /routes.rb
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end
The key and secret are configured as Geroku variables, and the application is registered on Github. By clicking on the link that you sent to Github, you authenticated and then sent back to the Github callback route with the code and all the information that auth performed.
The problem is that it is picked up by the users/omniiauth_callbacks controller failure method. I added a few put statements to find out where env['omniauth'] .
env['omniauth.auth'] has all the information from Github that he should.
env['omniauth.error'].response however is a OAuth2::Response with a lot of information, the important parts of which are:
@parsed={"error"=>"bad_verification_code"}, @error=
I'm wondering if this post really works, since Github now has its new v3 API .
One could just put the code I need into the callback controller's failure method, but it looks dirty and hacky.
Any suggestions would be highly appreciated.