LoginSignup
1
1

More than 5 years have passed since last update.

google_oauth2でredirect_uri_mismatch

Last updated at Posted at 2015-08-17

現象

Error: redirect_uri_mismatch

The redirect URI in the request: https://sample.com:80/users/auth/google_oauth2/callback did not match a registered redirect URI.

原因

protcolがhttpsなのにportが80を指定している
リバースプロキシをやっていて、nginxからapacheにリクエストを渡すときは80に渡しているから?

対策

callback_urlはここで定義されている
https://github.com/intridea/omniauth/blob/master/lib/omniauth/strategy.rb#L431

「parameterとしてredirect_uriを指定して渡す」でとりあえず対応した

user_omniauth_authorize_path(:google_oauth2, redirect_uri: Settings.omniauth.redirect_uri)

config/settings/production

omniauth:
  redirect_uri: 'http://sample.com/users/auth/google_oauth2/callback'

追記

redirect_uriをhttpsで指定するとredirect_uri_mismatchが発生する

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