redirect_uri_mismatch. Login with Google using Rub

2020-02-15 08:30发布

问题:

I'm trying to add Google Login to my app using omniauth-google-oauth2 gem.

I have created the client Id and secret in console.developers.google.com and added redirect_uri as follows.

routes.rb

get 'auth/:provider/callback', to: 'people#socialmedialogin',:as => :callback

Gemfile

gem 'omniauth-oauth2', '~> 1.4.0'
gem "omniauth-google-oauth2"

I am facing the problem in signing in. It is authenticating with Google and fails to redirect. Error is as follows.

redirect_uri_mismatch: { "error" : "redirect_uri_mismatch" }

Extracted source (around line #113):

  when 400..599
    error = Error.new(response)
    raise(error) if opts.fetch(:raise_errors, options[:raise_errors])
    response.error = error
    response
  else
    .....

回答1:

Try to downgrade the gem (could be compatibility problem) :

gem 'omniauth-oauth2', '~> 1.3.1'