0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

omniauth-backlogでredirect_uri_mismatchエラーへの対応

Last updated at Posted at 2019-02-15

発生した問題

Railsでomniauth-backlog を使って、Nulab BacklogでのOAuth2認証を行いたいが、下記のようなエラーが出て認証が通らない。

OAuth2::Error (invalid_request: redirect_uri_mismatch
{"error":"invalid_request","error_description":"redirect_uri_mismatch"}):

原因

リダイレクト時のURLが http://<RAILS_HOST>/auth/backlog/callback?code=xxx&state=yyy と、codeとstateパラメータが付いており、URLがマッチしないのが原因。

対応方法

config/initializers/omniauth.tb の 先頭 に以下のようなパッチをあてる。

OmniAuth::Strategies::Backlog.class_eval do
  def callback_url
    full_host + script_name + callback_path
  end
end

一番良い対応方法

現状 2015/08 から更新されてないので、本来このgemを使わず、自分で実装するのが一番良い解決策。(でも楽したいですよね)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?