0
0

Rails7 Heroku OmniauthのGitHub認証の際に"OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch"エラーが発生する

Last updated at Posted at 2023-10-01

This article shows how to resolve CallbackError when GitHub authorizing at Heroku.

環境情報&前提条件

  • Ruby 3.2.1
  • Rails 7.0.0
  • 開発環境
    • Docker使用
  • 本番環境
    • Herokuにデプロイ(stack heroku-22)

gem

  • devise 4.9.2
  • omniauth 2.1.1
  • omniauth-github 2.0.1

解決したい内容

  • ローカルの開発環境でOmniauthによるGitHub認証ができることを確認済み。
  • Heroku本番環境においてGitHub認証を実行すると、以下エラーが発生してGitHub認証に失敗する。
    • "OmniAuth::Strategies::OAuth2::CallbackError, redirect_uri_mismatch"

解決手順

  • config/initializers/devise.rbに以下を追記する。https://hoge.herokuapp.comの部分はご自身のアプリのURLに置換してください。
config/initializers/devise.rb
OmniAuth.config.full_host = 'https://hoge.herokuapp.com' if Rails.env.production?

参考記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0