得到“错误:redirect_uri_mismatch";与google_oauth2 [英] Getting "Error: redirect_uri_mismatch" with google_oauth2
问题描述
URL似乎正确(昨天最后一次更新):
The URL's seem right (Last updated them yesterday):
文件也是如此:
omniauth.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正常运行)
(Twitter and Facebook OmniAuth are working perfectly)
不确定是什么问题.有什么解决方法可以解决吗?
Not sure what is the problem. Any usggestions to fix this?
编辑
我将URI更改为http
...:
I changed the URI to http
...:
但仍然出现相同的错误.
But still getting the same error.
推荐答案
看起来请求已到达http://localhost:3000/auth/google_oauth2/callback
,但您匹配的类似格式的指定重定向URI适用于https
.将http://localhost:3000/auth/google_oauth2/callback
添加到您的重定向列表中可能会解决该问题.
It looks like the request is hitting http://localhost:3000/auth/google_oauth2/callback
, but your specified redirect URI matching the similar pattern is for https
. Adding http://localhost:3000/auth/google_oauth2/callback
to your list of redirects may potentially solve that issue.
编辑:另一个可能的解决方法是在相应的重定向URI中包含尾随/
,在这种情况下,该重定向似乎很有效.
Another potential fix is including a trailing /
in the corresponding redirect URIs, which appeared to work in this case.
这篇关于得到“错误:redirect_uri_mismatch";与google_oauth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!