atarihomestar atarihomestar - 2 months ago 24x
Ruby Question

Error: redirect_uri_mismatch when using omniauth-google-oauth2

I have signing in with Facebook working. I am now trying to get signing in with Google working.

I get Error: redirect_uri_mismatch and I can't figure out why.

I saw where somebody said to use omniauth-oauth2 v. 1.3.1 so I am.

My routes file includes:

gem 'omniauth-facebook'
gem 'omniauth-google-oauth2', '~> 0.4.1'
gem 'omniauth-oauth2', '~> 1.3.1'

My omniauth.rb file is:

Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], info_fields: 'email,first_name,last_name'
provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
:name => "google",
:scope => "email, profile,,",
:prompt => "select_account",
:image_aspect_ratio => "square",
:image_size => 50

I have taken the error message

The redirect URI in the request, http://localhost:3000/auth/google/callback, does not match the ones authorized for the OAuth client

and copied the uri, and then gone into the credientials page for the google api,and then added that exact uri as an Authorized Redirect URI.

Any help would be greatly appreciated.


In Enter your app’s URL plus


in “Authorized redirect URIs field. So It should be: