I have been attempting to add google auth to my signup page and have followed the steps in the guide but once I sign in to my google account, I get redirected to localhost:3000/# and have the following error in my console:
E, [2018-01-02T18:21:05.351019 #57341] ERROR -- omniauth: (google_oauth2) Authentication failure! invalid_credentials: OAuth2::Error, redirect_uri_mismatch:
{ "error" : "redirect_uri_mismatch" }
I have tried all the solutions in this existing stackoverflow thread but none of these solutions that have worked for these users have worked for me.
My devise.rb:
Devise.setup do |config|
config.stretches = Rails.env.test? ? 1 : 11
config.extend_remember_period = true
config.password_length = 2..72
config.sign_out_all_scopes = false
config.sign_out_via = :get
OmniAuth.config.full_host = Rails.env.production? ?
'http://localhost:3000'
config.omniauth(:facebook,
Rails.application.secrets.facebook_app_id,
Rails.application.secrets.facebook_api_key,
image_size: :large)
config.omniauth(:google_oauth2,
Rails.application.secrets.google_client_id,
Rails.application.secrets.google_client_secret,
{:redirect_uri =>
"http://localhost:3000/users/auth/google_oauth2/callback"}
)
require('devise/orm/active_record')
end
routes.rb
r.devise_for(:users,
only: :omniauth_callbacks,
controllers: {omniauth_callbacks: :omniauth})
I have also added the following redirect uris to my google developers console:
https://localhost:3000/users/auth/google_oauth2/callback https://localhost:3000/users/auth/google_oauth2/callback/ http://localhost:3000/users/auth/google_oauth2/callback http://localhost:3000/users/auth/google_oauth2/callback/
Thank you in advance for your answers!