redirect_uri_mismatch.使用 Ruby on Rails 登录 Google [英] redirect_uri_mismatch. Login with Google using Ruby on Rails

查看:47
本文介绍了redirect_uri_mismatch.使用 Ruby on Rails 登录 Google的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 omniauth-google-oauth2 gem 将 Google 登录添加到我的应用中.

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

我在 console.developers.google.com 中创建了客户端 ID 和密码,并添加了如下所示的 redirect_uri.

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

宝石文件

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

我在登录时遇到问题.它正在通过 Google 进行身份验证,但无法重定向.错误如下.

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

推荐答案

尝试降级gem(可能是兼容性问题):

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

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

这篇关于redirect_uri_mismatch.使用 Ruby on Rails 登录 Google的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆