octokit.rb icon indicating copy to clipboard operation
octokit.rb copied to clipboard

exchange_code_for_token rising bad_verification_code

Open mbajur opened this issue 4 years ago • 0 comments

Hello!

I'm trying to integrate omniauth-github in my devise-based app and i encountered an issue with octokit/github API.

On the callback route, after successfully signing-in, when trying to use a code returned by github, exchange_code_for_token gives me bad_verification_code error. I know this might not be related to octokit gem but i double-checked everything, my client id/secret are exactly the same as the ones used for omniauth setup, sign-in process goes fine (because i have access to user info on callback route), it's just the exchange_code_for_token part is broken.

My code looks as follows:

# devise.rb
config.omniauth :github, ENV['GITHUB_APP_ID'], ENV['GITHUB_SECRET'], scope: 'user,public_repo'

# omniauth_callbacks_controller.rb
def github
  Octokit.exchange_code_for_token(params[:code], ENV['GITHUB_APP_ID'], ENV['GITHUB_SECRET'], )
end
  • rails 6.0.2.2
  • Octokit 4.17.0
  • ruby 2.7.0

mbajur avatar Mar 25 '20 10:03 mbajur