I'm getting this error: OAuth2::Error redirect_uri_mismatch
This is how I have omniauth.rb set up, per omniauth-google-oauth2's documentation.
# config/initializers/omniauth.rb
OmniAuth.config.logger = Rails.logger
OmniAuth.config.full_host = Rails.env.production? ? 'https://www.********.org' : 'http://localhost:3000'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_OAUTH_CLIENT_ID'], ENV['FACEBOOK_OAUTH_SECRET']
provider :google_oauth2, ENV['GOOGLE_OAUTH_CLIENT_ID'], ENV['GOOGLE_OAUTH_SECRET'], {scope: 'profile', image_aspect_ratio: 'square', image_size: 48, access_type: 'online'}
end
And this is how I have my routes.rb set up to handle the callback:
# config/routes.rb
get 'auth/:provider/callback', to: 'sessions#create'
Here's a screenshot of my Google Developer Console, where I have my authorized redirect uri set up as http://localhost:3000/auth/google_oauth2/callback
.
I have tried it as just http://localhost:3000
and with https
and http://localhost/auth/google_oauth2/callback
and several other variations.
Some people say the console can take a while to update, so I wonder if it's possible I tried the correct thing at some point and didn't give it enough time (more than 5 minutes?) to update.
Facebook's callback (http://localhost:3000/auth/facebook/callback
at the Facebook developer console) works, taking me all the way through to the SessionsController's #create action, where I haven't added a way to handle it yet, so it's throwing an error there.
Can anyone spot what I'm doing wrong!?