octokit.rb
octokit.rb copied to clipboard
exchange_code_for_token rising bad_verification_code
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