gpt4 book ai didi

ruby-on-rails - 通过google_oauth2获取“错误:redirect_uri_mismatch”

转载 作者:行者123 更新时间:2023-12-03 14:43:29 28 4
gpt4 key购买 nike

URL似乎正确(昨天最后更新了它们):



这些文件也是:

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>


route.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添加到重定向列表中可能会解决该问题。

编辑:另一个可能的解决方法是在相应的重定向URI中包含尾随/,在这种情况下,它似乎可以正常工作。

关于ruby-on-rails - 通过google_oauth2获取“错误:redirect_uri_mismatch”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13204474/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com