简体   繁体   English

redirect_uri_mismatch。 使用Ruby on Rails与Google登录

[英]redirect_uri_mismatch. Login with Google using Ruby on Rails

I'm trying to add Google Login to my app using omniauth-google-oauth2 gem. 我正在尝试使用omniauth-google-oauth2 gem将Google登录名添加到我的应用中。

I have created the client Id and secret in console.developers.google.com and added redirect_uri as follows. 我已经在console.developers.google.com创建了客户端ID和密码,并按如下所示添加了redirect_uri。

在此处输入图片说明

routes.rb 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. 我在登录时遇到问题。它正在通过Google进行身份验证,无法重定向。 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降级(可能是兼容性问题):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM