LoginSignup
1
0

More than 5 years have passed since last update.

Rails devise omniauth-facebook で Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request

Last updated at Posted at 2015-11-28

現象

こんなエラーが出た。

Started GET "/users/auth/facebook/callback?redirect_uri=REDIRECT_URL&code=CODE&state=STATE" for ::1 at 2015-11-28 14:14:54 +0900
I, [2015-11-28T14:14:54.941266 #9383]  INFO -- omniauth: (facebook) Callback phase initiated.
E, [2015-11-28T14:14:56.362811 #9383] ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials: OAuth2::Error, :
{"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100,"fbtrace_id":"FACEBOOK_ID"}}
Processing by Users::OmniauthCallbacksController#failure as HTML
  Parameters: {"redirect_uri"=>"http://localhost:3000//", "code"=>"CODE", "state"=>"STATE"}
Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 88ms (ActiveRecord: 0.0ms)

対策

deviseのwikiを見ると

Note: v2.0.1 has an issue with callback url error. You need to add a callback url on config.

config.omniauth :facebook, "APP_ID", "APP_SECRET",
                callback_url: "CALLBACK_URL"

バージョン固有の問題かもしれない。
omniauth-facebookのバージョンをみると

omniauth-facebook (2.0.1)

バージョンにこだわりはなかったので、バージョンを上げてしまうことにする。

bundle update omniauth-facebook

解決した。

1
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
1
0