ruby-on-rails – 使用google_oauth2获取“错误:redirect_uri_mismatch”

网址似乎正确(昨天最后更新):

文件也是:

omn​​iauth.rb:

provider :google_oauth2,'MY_CLIENT_ID.apps.googleusercontent.com','MY_CLIENT_SECRET',:scope => 'https://mail.google.com/mail/feed/atom/'

Error: redirect_uri_mismatch
The redirect URI in the request: http://localhost:3000/auth/google_oauth2/callback did not match a registered redirect URI

header.html.erb

<li><%= link_to "Sign in with Google","auth/google_oauth2" %></li>

routes.rb中:

match '/auth/:provider/callback',to: 'sessions#omniauth_create'

但我得到这个:

> Error: redirect_uri_mismatch The redirect URI in the request:
> http://localhost:3000/auth/google_oauth2/callback did not match a
> registered redirect URI

(Twitter和Facebook OmniAuth正在完美工作)

不确定是什么问题.有什么建议来解决这个问题?

编辑

我将URI更改为http …:

但仍然有相同的错误.

解决方法

看起来请求正在http:// localhost:3000 / auth / google_oauth2 / callback,但您指定的重定向URI匹配类似的模式是用于https.将http:// localhost:3000 / auth / google_oauth2 / callback添加到重定向列表中可能会解决这个问题.

编辑:另一个潜在的修复包括拖尾/在相应的重定向URIs,这似乎在这种情况下工作.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...