Create omniauth-github oauth2 "bad_verification_code" error

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=#<OAuth2::Error: OAuth2::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.

+4
source share
1 answer

I'm not sure if this will help, but only yesterday, when I tried to authenticate with github using the omniauth stone, I got the same errors.

In the end, I ended up doing this in the github way of sending client_id, client_secret and redirect_uri to /github.com/oauth/authorize and got a callback for redirect_uri.

Here is the link

0
source

Source: https://habr.com/ru/post/1393645/


All Articles